IRONSOFTWAREHOME

How to Read QR Codes from Images in C#

Curtis Chau
Curtis Chau
Updated: August 2, 2026

IronQR enables developers to read QR codes from various image formats in C# by loading images with IronDrawing, creating a QrImageInput object, and using the QrReader.Read method to decode the QR data efficiently.

Quickstart: Read QR Code from Image in C#

How Do I Read QR Codes from Different Image Formats?

IronQR provides built-in support for reading QR codes from various image formats. This functionality uses advanced machine learning models to ensure accurate decoding across different media types. The supported formats include:

  • 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 format support is enabled by the open-source library IronDrawing, which handles image processing efficiently. You can process QR codes from digital cameras, scanners, mobile devices, or web downloads without format conversion.

Sample QR code with clear black and white pattern showing positioning squares and data modules for testing image scanning
  1. 1Install IronQR with NuGet Package Manager

    PM > Install-Package IronQR

  2. 2Copy and run this code snippet.

    // Import necessary IronQR and IronDrawing namespaces
    using IronSoftware.Drawing; 
    using IronQr;
    
    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);
    
                // Create a QR Reader and decode the QR code from the image
                var reader = new QrReader();
                var results = reader.Read(qrImageInput);
    
                // Iterate through each detected QR code and display its information
                foreach (var qrResult in results)
                {
                    Console.WriteLine($"QR Code Data: {qrResult.Value}");
                }
            }
        }
    }
    C#
  3. 3Deploy to test on your live environment

    Start using IronQR in your project today with a free trial
    arrow pointer

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!

Why Does IronQR Support Multiple Image Formats?

Reading a QR code refers to 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.

IronQR's multi-format support is essential for real-world applications where QR codes appear in various contexts - from marketing materials and product packaging to digital documents and web content. By supporting diverse formats, IronQR ensures developers can build robust applications without worrying about image format compatibility. Learn more about IronQR's read capabilities to understand how this flexibility enhances your development workflow.

When Should I Use Each Image Format?

Different image formats serve different purposes in QR code processing:

  • PNG: Best for QR codes requiring transparency or when image quality is paramount. PNG's lossless compression ensures QR code patterns remain crisp and readable.
  • JPEG: Ideal for photographs containing QR codes or when file size is a concern. Use higher quality settings (80%+) to prevent compression artifacts from affecting readability.
  • TIFF: Perfect for archival purposes or when working with scanned documents in enterprise environments.
  • WebP: Modern format offering excellent compression with quality retention, ideal for web applications.

For optimal results with any format, ensure your images maintain sufficient resolution (at least 300 DPI for printed QR codes) and contrast. Check out our advanced QR reading examples for format-specific optimization techniques.

What Happens If the Image Quality Is Poor?

IronQR incorporates fault tolerance features to handle imperfect images. When dealing with poor quality images, the library employs several strategies:

  1. Error Correction: QR codes include error correction capabilities (L, M, Q, H levels), allowing data recovery even when up to 30% of the code is damaged.
  2. Machine Learning Enhancement: IronQR's ML models detect and compensate for common issues like blur, distortion, and poor lighting.
  3. Preprocessing: Automatic image enhancement improves contrast and sharpness before decoding attempts.

For challenging scenarios, consider using custom QR read mode options to fine-tune the reading process:

// Example: Reading QR codes from a poor quality image
using IronQr;

public class EnhancedQRReader
{
    public static void ReadPoorQualityImage()
    {
        using (var inputImage = Image.FromFile("blurry_qr_code.jpg"))
        {
            // Create a QrImageInput and read with a QR Reader
            var qrImageInput = new QrImageInput(inputImage);
            var reader = new QrReader();
            var results = reader.Read(qrImageInput);
            
            foreach (var result in results)
            {
                Console.WriteLine($"Decoded: {result.Value}");
            }
        }
    }
}
C#

Retrieving Values from a QR Code

Most IronQR functions return a collection to support multiple detections. Since results is a sequence of objects, it does not have a Value property itself. The example code specifically selects the first QrResult from the collection and retrieves its Value.

using System;
using System.Collections.Generic;
using System.Linq;
using IronQr;
using System.Drawing;

// Import image
var inputImage = Image.FromFile("sample.jpg");

// Load the asset into QrImageInput
QrImageInput imageInput = new QrImageInput(inputImage);

// Create a QR Reader object
QrReader reader = new QrReader();

// Read the Input an get all embedded QR Codes
IEnumerable<QrResult> results = reader.Read(imageInput);

// Display the value of the first QR code found
Console.WriteLine($"QR code value is {results.First().Value}");

Detecting QR Code Position in an image

IronQR goes beyond simple decoding to precisely locate where a QR code sits within an image. This positioning uses a standard coordinate system where PointF (0,0) represents the top-left corner of the image. The exact spatial coordinates of the QR code's corners are accessible through the Points[] array.

In the example, the coordinates for all four points of the detected QR code are retrieved and printed to the console.

Please note: The coordinates that are returned by this function are stored in a strict "zig-zag" sequence: top-left, top-right, bottom-left, and finally, bottom-right
using System;
using System.Collections.Generic;
using IronQr;
using System.Drawing;
using System.Linq;

// Import an image containing a QR code
var inputImage = Image.FromFile("urlQr.png");

// Load the asset into a QrImageInput object
var imageInput = new QrImageInput(inputImage);

// Create a QR Reader object
var reader = new QrReader();

// Read the input and get all embedded QR codes
IEnumerable<QrResult> results = reader.Read(imageInput);

// [TL, TR, BL, BR]
string[] labels = { "Top-Left", "Top-Right", "Bottom-Left", "Bottom-Right" };

var points = results.First().Points;

for (int i = 0; i < points.Length; i++)
{
    Console.WriteLine($"{labels[i]}: {points[i].X}, {points[i].Y}");
}

Input QR Code

QR code

Output

Notice that the system has logged the exact spatial coordinates of every QR code corner to the console.

Edge Detection QR

Supported QR Code Types

Multiple types of QR codes are supported for both creation and reading. IronQR provides comprehensive support for various QR code formats to meet diverse application needs. Learn more about supported QR formats in our documentation. Below are the supported QR code types:

  • QRCode: The standard QR code most commonly used today. It can store up to 7,089 numeric characters or 4,296 alphanumeric characters, making it suitable for website URLs, contact information, and other applications.
Sample QR code with clear black and white pattern showing positioning squares and data modules for testing image scanning
  • MicroQRCode: A smaller version of the standard QR code designed for limited space. It can store up to 35 numeric characters or 21 alphanumeric characters, ideal for small packaging or tiny printed labels.
Standard QR code with finder patterns and data modules demonstrating typical QR code structure
  • RMQRCode: RMQR Code (Rectangular Micro QR Code) is a compact rectangular version rather than square. This version allows flexibility in aspect ratio, useful for applications where rectangular space is available.
Rectangular QR code example showing non-square format with standard positioning markers and data patterns

How Do I Choose the Right QR Code Type?

Selecting the appropriate QR code type depends on your specific use case and constraints:

  • Standard QR Code: Choose this for general-purpose applications where space isn't limited and you need maximum data capacity. Perfect for URLs, WiFi credentials, vCard contacts, or detailed product information. See our QR code generation examples for implementation details.
  • Micro QR Code: Ideal when working with small surfaces like electronic components, jewelry tags, or medical devices. Despite limited capacity, it's perfect for serial numbers, simple URLs, or basic tracking codes.
  • RMQR Code: Select rectangular codes when your available space has specific dimensional constraints, such as narrow labels on cylindrical products or elongated spaces on packaging edges.

What Are the Data Storage Limitations?

Understanding data capacity helps optimize your QR code implementation:

QR Code TypeNumeric OnlyAlphanumericBinaryKanji
Standard QR7,0894,2962,9531,817
Micro QR3521159
RMQRVariableVariableVariableVariable

Consider these factors when planning data storage:

  • Use URL shorteners for web links to maximize available space
  • Implement data compression for large datasets
  • Choose appropriate error correction levels (higher correction reduces capacity)

For advanced implementations, explore our styled QR code generation guide to balance aesthetics with data capacity.

When Should I Use Micro or RMQR Codes?

Micro and RMQR codes excel in specific scenarios:

Micro QR Codes are perfect for:

  • Electronic circuit boards requiring component tracking
  • Small medical devices needing patient or medication identifiers
  • Jewelry authentication with limited engraving space
  • Miniature product labels in manufacturing

RMQR Codes work best for:

  • Narrow shipping labels on tubes or pipes
  • Elongated spaces on pen barrels or tools
  • Banner-style marketing materials
  • Integration into existing rectangular design elements

Here's a practical example for reading different QR code types:

using IronQr;
using IronSoftware.Drawing;

public class MultiTypeQRReader
{
    public static void ReadVariousQRTypes()
    {
        string[] imagePaths = {
            "standard_qr.png",
            "micro_qr.png", 
            "rectangular_qr.png"
        };

        // Create a QR Reader that handles all QR code types
        var reader = new QrReader();

        foreach (var path in imagePaths)
        {
            using (var image = Image.FromFile(path))
            {
                var qrInput = new QrImageInput(image);
                var results = reader.Read(qrInput);
                
                foreach (var qr in results)
                {
                    Console.WriteLine($"Type: {qr.QrType}");
                    Console.WriteLine($"Data: {qr.Value}");
                    Console.WriteLine("---");
                }
            }
        }
    }
}
C#

For production deployments, review our NuGet packages guide to ensure you have the right package for your platform, and check the API reference for comprehensive documentation on all available methods and properties.

Frequently Asked Questions

How can I read QR codes from different image formats using IronQR?

IronQR supports reading QR codes from a wide range of image formats including JPEG, PNG, GIF, and more. This is achieved through advanced machine learning models that ensure accurate decoding across various media types, enabled by the IronDrawing library for efficient image processing.

What steps are involved in reading a QR code from an image in C# using IronQR?

To read a QR code from an image using IronQR, you need to download the IronQR library, import image data with IronDrawing, create a QrImageInput object, pass it to the QrReader.Read method, and iterate through each detected QR code to review its information.

Why is it important for IronQR to support multiple image formats?

Supporting multiple image formats allows IronQR to be versatile in real-world applications, where QR codes can be present in diverse contexts such as marketing materials, product packaging, digital documents, and web content. This ensures that developers can build applications without format compatibility issues.

What image format should I use for reading QR codes with IronQR?

The choice of image format depends on your needs. Use PNG for QR codes needing transparency, JPEG for photographs with QR codes, TIFF for archival purposes, and WebP for web applications due to its excellent compression. Ensure images have sufficient resolution and contrast for best results.

How does IronQR handle poor quality images?

IronQR uses fault tolerance features like error correction and machine learning models to compensate for issues like blur or poor lighting. It automatically enhances image contrast and sharpness, and offers custom QR read mode options for challenging conditions.

What types of QR codes can IronQR read?

IronQR can read various types of QR codes, including Standard QR Code, Micro QR Code, and RMQR Code, supporting different use cases and data capacities for applications requiring compact or rectangular formats.

When should I choose Micro or RMQR codes?

Choose Micro QR codes for small surfaces like circuit boards or medical devices and RMQR codes for rectangular labels like narrow shipping labels or marketing materials that require fitting into elongated spaces.

How does IronQR locate a QR code within an image?

IronQR uses a standard coordinate system to pinpoint where a QR code is located within an image. It retrieves and prints the exact spatial coordinates of the QR code's corners using the Points[] array.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...
Read More

Ready to Get Started?

Nuget Downloads 74,386Version:2026.9just released

Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package IronQR
nuget.org/packages/IronQR/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronQR"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

  1. Download and unzip IronQR to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronQR.dll"

Licenses from $999

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required