How to Read QR Code from Images

Reading a QR code refers to the process of scanning and decoding the information stored within a QR code. This is typically done using a camera or scanner paired with software that can interpret the QR code's data. The information in a QR code could be text, URLs, contact details, or other forms of data.

Read QR Codes from Images

One of IronQR's standout features is its built-in capability to read QR codes from various image formats seamlessly. This includes:

  • Joint Photographic Experts Group (JPEG)
  • Portable Network Graphics (PNG)
  • Graphics Interchange Format (GIF)
  • Tagged Image File Format (TIFF)
  • Bitmap Image File (BMP)
  • WBMP
  • WebP
  • Icon (ico)
  • WMF
  • RawFormat (raw)

This functionality is enabled by the open-source library, IronDrawing. Let's now explore how IronQR can be used to read QR codes from an image.

QR code
// Import necessary IronQR and IronDrawing namespaces
using IronSoftware.Drawing; 
using IronBarcode;

public class QRCodeReader
{
    public static void Main()
    {
        // Load an image from a file path
        using (var inputImage = Image.FromFile("path/to/your/image/file.webp"))
        {
            // Create a QrImageInput object from the image
            var qrImageInput = new QrImageInput(inputImage);

            // Decode the QR code from the image
            var result = BarcodeReader.Read(qrImageInput);

            // Iterate through each detected QR code and display its information
            foreach (var barcodeResult in result.Barcodes)
            {
                Console.WriteLine($"QR Code Data: {barcodeResult.Value}");
            }
        }
    }
}
// Import necessary IronQR and IronDrawing namespaces
using IronSoftware.Drawing; 
using IronBarcode;

public class QRCodeReader
{
    public static void Main()
    {
        // Load an image from a file path
        using (var inputImage = Image.FromFile("path/to/your/image/file.webp"))
        {
            // Create a QrImageInput object from the image
            var qrImageInput = new QrImageInput(inputImage);

            // Decode the QR code from the image
            var result = BarcodeReader.Read(qrImageInput);

            // Iterate through each detected QR code and display its information
            foreach (var barcodeResult in result.Barcodes)
            {
                Console.WriteLine($"QR Code Data: {barcodeResult.Value}");
            }
        }
    }
}
' Import necessary IronQR and IronDrawing namespaces
Imports IronSoftware.Drawing
Imports IronBarcode

Public Class QRCodeReader
	Public Shared Sub Main()
		' Load an image from a file path
		Using inputImage = Image.FromFile("path/to/your/image/file.webp")
			' Create a QrImageInput object from the image
			Dim qrImageInput As New QrImageInput(inputImage)

			' Decode the QR code from the image
			Dim result = BarcodeReader.Read(qrImageInput)

			' Iterate through each detected QR code and display its information
			For Each barcodeResult In result.Barcodes
				Console.WriteLine($"QR Code Data: {barcodeResult.Value}")
			Next barcodeResult
		End Using
	End Sub
End Class
$vbLabelText   $csharpLabel

Note: Replace "path/to/your/image/file.webp" with the actual path to your QR code image file.

Curious about the QR code value in the sample images? Give it a try using the code snippet!


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.
Micro 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.
Rectangular QR code

Frequently Asked Questions

How can I read a QR code from an image in C#?

To read a QR code from an image in C#, download the IronQR library from NuGet, use IronDrawing to import the image data, create a QrImageInput object, and use the Read method to decode the QR code.

What image formats are supported for reading QR codes?

IronQR supports reading QR codes from various image formats, including JPEG, PNG, GIF, TIFF, BMP, WBMP, WebP, ICO, WMF, and raw formats.

What types of QR codes can IronQR read?

IronQR can read different types of QR codes, including the standard QRCode, MicroQRCode, and RMQRCode, each designed for various data capacities and space requirements.

How does IronQR handle different QR code sizes?

IronQR can handle standard QR codes, which store large amounts of data, as well as more compact versions like MicroQRCode and RMQRCode, which are suitable for smaller or rectangular spaces.

How can I test the QR code reading functionality in IronQR?

To test the QR code reading functionality in IronQR, use the provided C# code snippet, ensuring to replace 'path/to/your/image/file.webp' with the actual path to your QR code image file.

What software components are needed to interpret QR code data from images?

To interpret QR code data from images, you need the IronQR library along with IronDrawing to handle image data and decode the QR codes.

Can IronQR work with non-square QR codes?

Yes, IronQR can work with non-square QR codes such as RMQRCode, which is a rectangular version suitable for applications with non-square spaces.

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