How to Create a QR Code as an Image

Creating a QR code as an image involves generating a visual representation of a QR code, which encodes data (such as a URL, text, or other information) in a two-dimensional matrix composed of black and white squares. These squares can be scanned and decoded by a camera or QR code reader.

Start using IronQR in your project today with a free trial.

First Step:
green arrow pointer

Create QR Code as Images

Creating a QR code with IronQR is very simple. You only need one line of code to create the QR code as an object. To export the QR code as an image, use the Save method followed by the SaveAs method.

:path=/static-assets/qr/content-code-examples/how-to/create-qr-code-image.cs
using IronQr;
using IronSoftware.Drawing;

// Creating a QR code
QrCode qrCode = QrWriter.Write("12345");

// Save QR code to AnyBitmap
AnyBitmap anyBitmap = qrCode.Save();

// Save AnyBitmap to PNG
anyBitmap.SaveAs("simpleQrCode.png", AnyBitmap.ImageFormat.Png);
Imports IronQr
Imports IronSoftware.Drawing

' Creating a QR code
Private qrCode As QrCode = QrWriter.Write("12345")

' Save QR code to AnyBitmap
Private anyBitmap As AnyBitmap = qrCode.Save()

' Save AnyBitmap to PNG
anyBitmap.SaveAs("simpleQrCode.png", AnyBitmap.ImageFormat.Png)
$vbLabelText   $csharpLabel
QR code

The Save method returns an AnyBitmap object. With this object, we can export to various image formats, such as:

  • JPEG (.jpg or .jpeg): JPEG is a commonly used compressed format for digital photos. It uses lossy compression, reducing file size while maintaining acceptable quality.
  • PNG (.png): PNG is a lossless image format ideal for web use. It supports transparency and retains high quality without data loss.
  • Bmp (.bmp): The Bitmap format is an uncompressed raster image format used primarily on Windows platforms. It retains high-quality images but produces large file sizes.
  • GIF (.gif): GIF supports animations and transparency but is limited to 256 colors. It is widely used for simple web graphics and short animations.
  • TIFF (.tiff or .tif): TIFF is a flexible format used for high-quality images, often in professional photography. It can be lossless or compressed.
  • WBMP (.wbmp): WBMP is a monochrome format used in wireless communication. If unsupported, it defaults to BMP.
  • WebP (.webp): WebP is a modern image format that provides excellent compression (both lossy and lossless), making it ideal for the web.
  • Icon (.ico): Icon format stores small square images used as icons for programs or files, commonly in operating systems.
  • WMF (.wmf): WMF is a vector and raster image format used primarily on Windows. It is often used for graphics in legacy systems.
  • RawFormat (.raw): Raw format refers to unprocessed image data, typically used in digital photography. It retains maximum quality and is used by professionals for image editing.

Supported QR Code Types

Multiple types of QR codes are supported for both creation and reading. Below are the supported QR code types:

  • QRCode: This is the standard QR code most commonly used today. It can store a significant amount of data (up to 7,089 numeric characters or 4,296 alphanumeric characters), making it suitable for a wide range of applications, from website URLs to contact information.
QR code
  • MicroQRCode: The Micro QR Code is a smaller version of the standard QR code, designed for situations where space is limited. It can store less data than a standard QR code (up to 35 numeric characters or 21 alphanumeric characters), but its compact size makes it ideal for applications where a standard QR code would be too large, such as on small packaging or tiny printed labels.
QR code
  • RMQRCode: RMQR Code (Rectangular Micro QR Code) is another compact version of the QR code but in a rectangular shape rather than a square. This version allows for flexibility in its aspect ratio, which can be useful for applications where a rectangular space is available. It can store data similar to the Micro QR Code but is designed for specific use cases where the available space is non-square.
QR code

Frequently Asked Questions

How can I create a QR code as an image in C#?

To create a QR code as an image in C#, download the IronQR library from NuGet. Create a QR code object with your desired data, then use the Save method to generate an AnyBitmap. Finally, use the SaveAs method to export it to an image format like PNG or JPEG.

What is the easiest way to export QR code images in different formats?

Using IronQR, you can export QR code images in various formats by utilizing the SaveAs method on the AnyBitmap object. Supported formats include JPEG, PNG, BMP, GIF, TIFF, WBMP, WebP, Icon, WMF, and RawFormat.

What types of QR codes are supported for creation?

IronQR supports creating standard QRCode, MicroQRCode, and RMQRCode types. Standard QRCode is used for large data, MicroQRCode for limited data in small spaces, and RMQRCode offers a rectangular shape for specific applications.

How do I make a QR code with a transparent background?

To create a QR code with a transparent background using IronQR, export the QR code as a PNG file, as the PNG format supports transparency.

What are the advantages of using the WebP format for QR codes?

The WebP format offers excellent compression, both lossy and lossless, making it ideal for web use due to its reduced file size and maintained image quality.

Can IronQR be used to encode URLs into QR codes?

Yes, IronQR can encode URLs into QR codes. Simply pass the URL as a string to the QRCodeWriter's CreateQrCode method.

What is the difference between JPEG and PNG formats for QR codes?

JPEG is a lossy compressed format suitable for reducing file size while maintaining acceptable quality, while PNG is a lossless format ideal for web use, maintaining high quality with support for transparency.

What is a Micro QR Code?

A Micro QR Code is a smaller version of the standard QR code, designed for limited space situations, storing less data but being more compact and suitable for applications like small packaging.

How can the rectangular shape of an RMQRCode be useful?

The RMQRCode's rectangular shape allows for aspect ratio flexibility, making it suitable for applications where space is non-square, providing more design options for printed materials.

Chaknith Bin
Software Engineer
Chaknith works on IronXL and IronBarcode. He has deep expertise in C# and .NET, helping improve the software and support customers. His insights from user interactions contribute to better products, documentation, and overall experience.
Talk to an Expert Five Star Trust Score Rating

Ready to Get Started?

Nuget Passed