Test in production without watermarks.
Works wherever you need it to.
Get 30 days of fully functional product.
Have it up and running in minutes.
Full access to our support engineering team during your product trial
QR codes (Quick Response Codes) are everywhere—on product packaging, event tickets, menus, and even business cards. As a .NET developer, being able to quickly and reliably read QR codes from images can open the door to powerful automation and user interaction features. In this guide, we’ll walk you through how to use IronQR, a high-performance QR code library built specifically for .NET, to read QR codes from images with just a few lines of C# code.
Whether you’re building inventory management software, integrating two-factor authentication, or simply decoding URLs from screenshots, IronQR makes it easy.
'Broken image'
Clear alt text
IronQR is a powerful C# QR code library developed to create a powerful QR code reader and writer for .NET developers. IronQR is designed for both QR code generation and scanning, and it supports reading from a variety of image formats, making it ideal for use in desktop, web, or server applications. Through this library, you can create accurate QR code reader tools to automate the entire process of QR code recognition and reading.
Unlike open-source alternatives, IronQR focuses on enterprise-grade stability, commercial licensing, and professional support—making it an excellent fit for business-critical applications.
Before you can start scanning QR codes, let’s walk through how to set up IronQR in your .NET application.
You can install IronQR directly from the NuGet Package Manager Console:
Install-Package IronQR
Install-Package IronQR
Alternatively, use the NuGet GUI in Visual Studio by searching for IronQR, and click "Install":
Add from PixabayUpload
or drag and drop an image here
Clear alt text
Once installed, include the following namespace in your C# file:
using IronSoftware.Drawing;
using IronQR;
using IronSoftware.Drawing;
using IronQR;
Note: IronSoftware.Drawing is used for handling image formats in a cross-platform manner.
Let’s dive into how to actually read a QR code from a file using IronQR.
IronQR supports multiple types of image formats, including:
This flexibility allows you to work with virtually any image source, from camera snapshots to scanned documents.
Let's take a closer look at how you can use this library to decode QR codes with ease. Here’s a minimal example that reads a single QR code with the text value "Hello World!" from an image file, using the Bitmap class and a file stream to load the image:
using IronQr;
using IronSoftware.Drawing;
using System;
class Program
{
static void Main()
{
// Load the image using a file stream
using var stream = File.OpenRead("sample-qr.png");
var bitmapImage = AnyBitmap.FromStream(stream);
QrImageInput qrImageInput = new QrImageInput(bitmapImage );
// Read the QR code
QrReader qrReader = new QrReader();
try
{
// Use the QR read method to read the values within your QR code(s)
IEnumerable<QrResult> results = qrReader.Read(qrImageInput);
// Output the decoded value
foreach (var result in results)
{
Console.WriteLine("QR Code Value: " + result.Value);
}
}
catch (Exception ex)
{
Console.WriteLine("Error reading QR code: " + ex.Message);
}
}
}
using IronQr;
using IronSoftware.Drawing;
using System;
class Program
{
static void Main()
{
// Load the image using a file stream
using var stream = File.OpenRead("sample-qr.png");
var bitmapImage = AnyBitmap.FromStream(stream);
QrImageInput qrImageInput = new QrImageInput(bitmapImage );
// Read the QR code
QrReader qrReader = new QrReader();
try
{
// Use the QR read method to read the values within your QR code(s)
IEnumerable<QrResult> results = qrReader.Read(qrImageInput);
// Output the decoded value
foreach (var result in results)
{
Console.WriteLine("QR Code Value: " + result.Value);
}
}
catch (Exception ex)
{
Console.WriteLine("Error reading QR code: " + ex.Message);
}
}
}
Console Output
Add from PixabayUpload
or drag and drop an image here
Clear alt text
This code loads the QR code image, reads the first detected QR code, and prints the decoded content. Simple and effective. From here, you can save the QR codes value's for further use.
If your image contains multiple QR codes (e.g., a sheet of product labels), you can extract all of them. For this example, we'll run the following QR Code image through our program:
Add from PixabayUpload
or drag and drop an image here
Clear alt text
using IronQr;
using IronSoftware.Drawing;
using System;
class Program
{
static void Main()
{
// Load the image from file
var inputImage = AnyBitmap.FromFile("SampleCodes.png");
QrImageInput qrImageInput = new QrImageInput(inputImage);
// Read the QR code
QrReader qrReader = new QrReader();
IEnumerable<QrResult> results = qrReader.Read(qrImageInput);
// Output the decoded value
foreach (var result in results)
{
Console.WriteLine("QR Code Value: " + result.Value);
}
}
}
using IronQr;
using IronSoftware.Drawing;
using System;
class Program
{
static void Main()
{
// Load the image from file
var inputImage = AnyBitmap.FromFile("SampleCodes.png");
QrImageInput qrImageInput = new QrImageInput(inputImage);
// Read the QR code
QrReader qrReader = new QrReader();
IEnumerable<QrResult> results = qrReader.Read(qrImageInput);
// Output the decoded value
foreach (var result in results)
{
Console.WriteLine("QR Code Value: " + result.Value);
}
}
}
Output
Add from PixabayUpload
or drag and drop an image here
Clear alt text
Here are a few real-world scenarios where reading QR codes from images becomes valuable:
In all these use cases, fast and accurate recognition is key—something IronQR handles with ease.
If you run into issues reading QR codes, consider the following:
Blurry or low-resolution images can make it difficult to detect a QR code. Use high-quality inputs when possible.
Make sure the image is not too dark, has strong contrast, and that the QR code is not obscured. Try cropping the image to focus on the QR region.
Always wrap your QR reading logic in try-catch blocks to gracefully handle corrupted files or unexpected formats:
try
{
IEnumerable<QrResult> results = qrReader.Read(qrImageInput);
// Output the decoded value
foreach (var result in results)
{
Console.WriteLine("QR Code Value: " + result.Value);
}
}
catch (Exception ex)
{
Console.WriteLine("Error reading QR code: " + ex.Message);
}
try
{
IEnumerable<QrResult> results = qrReader.Read(qrImageInput);
// Output the decoded value
foreach (var result in results)
{
Console.WriteLine("QR Code Value: " + result.Value);
}
}
catch (Exception ex)
{
Console.WriteLine("Error reading QR code: " + ex.Message);
}
Reading QR codes from images in C# doesn’t have to be difficult. With IronQR, you can integrate QR code scanning into your .NET applications with just a few lines of code. Its simplicity, cross-platform compatibility, and excellent performance make it a go-to tool for developers working on modern, QR-enabled systems.
If you're looking to extend this functionality, consider exploring:
Install the IronQR free trial to get started today, and learn how this library can elevate your QR code tasks.