How to Read QR Code from Images

This article was translated from English: Does it need improvement?
Translated
View the article in English

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

常見問題解答

如何在 C# 中從圖像中讀取 QR 碼?

要在 C# 中從圖像中讀取 QR 碼,從 NuGet 下載 IronQR 庫,使用 IronDrawing 導入圖像數據,創建一個 QrImageInput 物件,然後使用 Read 方法解碼 QR 碼。

支持哪些圖像格式用於讀取 QR 碼?

IronQR 支持從各種圖像格式中讀取 QR 碼,包括 JPEG、PNG、GIF、TIFF、BMP、WBMP、WebP、ICO、WMF 和原始格式。

IronQR 可以讀取哪些類型的 QR 碼?

IronQR 可以讀取不同類型的 QR 碼,包括標準 QRCode、MicroQRCode 和 RMQRCode,每種類型的設計都適合不同的數據容量和空間要求。

IronQR 如何處理不同大小的 QR 碼?

IronQR 可以處理可存儲大量數據的標準 QR 碼,以及更緊湊的版本如 MicroQRCode 和 RMQRCode,這些都適合較小或矩形空間。

如何測試 IronQR 中的 QR 碼讀取功能?

要測試 IronQR 中的 QR 碼讀取功能,使用提供的 C# 代碼片段,確保將 'path/to/your/image/file.webp' 替換為 QR 碼圖像文件的實際路徑。

需要哪些軟件組件來解釋從圖像中提取的 QR 碼數據?

要解釋從圖像中提取的 QR 碼數據,您需要 IronQR 庫以及 IronDrawing 來處理圖像數據並解碼 QR 碼。

IronQR 能處理非正方形的 QR 碼嗎?

是的,IronQR 能處理像 RMQRCode 這樣的非正方形 QR 碼,這是一種適用於非正方形空間應用的長方形版本。

Curtis Chau
技術作家

Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。

除了開發之外,Curtis 對物聯網 (IoT) 有著濃厚的興趣,探索將硬體和軟體結合的創新方式。在閒暇時間,他喜愛遊戲並構建 Discord 機器人,結合科技與創意的樂趣。

準備好開始了嗎?
Nuget 下載 47,669 | 版本: 2025.11 剛剛發布