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. This matrix is composed of black and white squares that 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)
VB   C#
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