Cómo leer códigos de barras de imágenes GIF y TIFF de varias páginas en C#

How to Read Barcodes from Multi-Page/Frame GIF and TIFF

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

IronBarcode supports various image format inputs for reading, including multi-page and multi-frame GIF and TIFF image formats. This offers ease of use for users to simply use the image without manually separating the frames or pages of a TIFF or GIF file. Let's explore how to use IronBarcode to read these file formats.

Quickstart: Reading Barcodes Entirely from Multipage TIFF or GIF Files

With just one simple method call, IronBarcode can load a multipage TIFF or animated GIF and extract all barcodes. No frame splitting or manual preprocessing—just pass the file path to BarcodeReader.Read for fast results.

Nuget IconGet started making PDFs with NuGet now:

  1. Install IronBarcode with NuGet Package Manager

    PM > Install-Package BarCode

  2. Copy and run this code snippet.

    IronBarCode.BarcodeResults results = IronBarCode.BarcodeReader.Read("multiPageImage.tiff");
  3. Deploy to test on your live environment

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

Read Multiframe GIF and TIFF Images

Reading multiframe GIF and TIFF images using IronBarcode is as easy as reading a single image because IronBarcode readily accepts multipage image files into the BarcodeReader.Read method. The users do not have to do any image preparation as all of them have been internalized in the library.

The code example below demonstrates how to read multipage GIF and TIFF files:

:path=/static-assets/barcode/content-code-examples/how-to/read-barcodes-from-multi-page-frame-tiff-gif-read-tif.cs
using IronBarCode;
using System;

// Read barcode from TIF image
BarcodeResults results = BarcodeReader.Read("sample.tif");

// Output the barcodes value to console
foreach (var result in results)
{
    Console.WriteLine(result.Value);
}
Imports IronBarCode
Imports System

' Read barcode from TIF image
Private results As BarcodeResults = BarcodeReader.Read("sample.tif")

' Output the barcodes value to console
For Each result In results
	Console.WriteLine(result.Value)
Next result
$vbLabelText   $csharpLabel

Convert Images to GIF and TIFF

Learn how to convert images to multipage TIFF and GIF by utilizing our open-source library, IronDrawing. Now, let's look at the code example below on how to generate a multipage GIF or TIFF image.

:path=/static-assets/barcode/content-code-examples/how-to/read-barcodes-from-multi-page-frame-tiff-gif-create-tiff-gif.cs
using IronBarCode;
using IronSoftware.Drawing;
using System.Collections.Generic;

// Import images
List<AnyBitmap> images = new List<AnyBitmap>()
{
    AnyBitmap.FromFile("image1.png"),
    AnyBitmap.FromFile("image2.png"),
    AnyBitmap.FromFile("image3.png"),
    AnyBitmap.FromFile("image4.jpg"),
    AnyBitmap.FromFile("image5.jpg")
};

// Convert TIFF from images
AnyBitmap tiffImage = AnyBitmap.CreateMultiFrameTiff(images);

// Export TIFF
tiffImage.SaveAs("multiframetiff.tiff");

// Convert GIF from images
AnyBitmap gifImage = AnyBitmap.CreateMultiFrameGif(images);

// Export GIF
gifImage.SaveAs("multiframegif1.gif");
Imports IronBarCode
Imports IronSoftware.Drawing
Imports System.Collections.Generic

' Import images
Private images As New List(Of AnyBitmap)() From {AnyBitmap.FromFile("image1.png"), AnyBitmap.FromFile("image2.png"), AnyBitmap.FromFile("image3.png"), AnyBitmap.FromFile("image4.jpg"), AnyBitmap.FromFile("image5.jpg")}

' Convert TIFF from images
Private tiffImage As AnyBitmap = AnyBitmap.CreateMultiFrameTiff(images)

' Export TIFF
tiffImage.SaveAs("multiframetiff.tiff")

' Convert GIF from images
Dim gifImage As AnyBitmap = AnyBitmap.CreateMultiFrameGif(images)

' Export GIF
gifImage.SaveAs("multiframegif1.gif")
$vbLabelText   $csharpLabel

From the code snippet above, we first group a number of image files by importing them into a list of AnyBitmap objects. This list can then be used as a parameter when calling the AnyBitmap.CreateMultiFrameTiff and AnyBitmap.CreateMultiFrameGif methods to obtain the multipage TIFF and multipage GIF objects, respectively.

While both multipage GIF and TIFF offer a way to group images into a single file, there are several differences between the two formats, as outlined below:

Aspect Multipage GIF Multipage TIFF
Compression GIF images use lossless compression, meaning that no image data is lost during compression. This results in relatively larger file sizes compared to formats with lossy compression. TIFF files can use various compression methods, including lossless compression (such as LZW) and lossy compression (such as JPEG). This flexibility allows TIFF files to balance between file size and image quality.
Color Depth GIF supports up to 256 colors (8-bit color depth), which is limited compared to other formats. This limited color palette can result in a loss of detail and color accuracy, especially for photographs and images with gradients TIFF supports various color depths, including 1-bit (binary), 8-bit (256 colors), 24-bit (true color), and more. This flexibility allows TIFF to store images with different levels of color detail.
Transparency GIF supports binary transparency, which means that a single color can be fully transparent, and the rest of the colors are fully opaque. This lack of partial transparency can sometimes lead to jagged edges in images with smooth transitions. TIFF supports multiple forms of transparency, including binary transparency (similar to GIF) and alpha channel transparency. Alpha channel transparency allows for smooth transitions and semi-transparent pixels, providing high-quality transparency effects.
Animation GIF supports simple animations by combining multiple frames into a single file. Each frame can have its own time delay, creating a basic form of animation. GIF animations are widely supported on the web. TIFF is not primarily designed for animations. While it can store multiple images, it lacks built-in animation support like GIF. Each page in a multipage TIFF file is typically a separate image rather than a frame in an animation sequence.

Advanced Barcode Reading

Although IronBarcode works directly out of the box, some images may require configuring the BarcodeReaderOptions class to achieve accurate and fast barcode reading. You can find more information on this class in the 'How to read Barcodes from Image Files (jpg, png, gif, tiff, svg, bmp)' article.

The code snippet below provides examples of the necessary properties that can be configured in the BarcodeReaderOptions class.

:path=/static-assets/barcode/content-code-examples/how-to/read-barcodes-from-multi-page-frame-tiff-gif-advance.cs
using IronBarCode;
using System;

// Configure filters
ImageFilterCollection filters = new ImageFilterCollection()
{
    new SharpenFilter(3.5f),
    new ContrastFilter(2)
};

// Configure options
BarcodeReaderOptions options = new BarcodeReaderOptions()
{
    ExpectBarcodeTypes = IronBarCode.BarcodeEncoding.QRCode,
    ImageFilters = filters,
    ExpectMultipleBarcodes = true,
    Speed = ReadingSpeed.Balanced
};

// Read barcode from TIF image
BarcodeResults results = BarcodeReader.Read("sample.tif", options);

// Output the barcodes value to console
foreach (var result in results)
{
    Console.WriteLine(result.Value);
}
Imports IronBarCode
Imports System

' Configure filters
Private filters As New ImageFilterCollection() From {
	New SharpenFilter(3.5F),
	New ContrastFilter(2)
}

' Configure options
Private options As New BarcodeReaderOptions() With {
	.ExpectBarcodeTypes = IronBarCode.BarcodeEncoding.QRCode,
	.ImageFilters = filters,
	.ExpectMultipleBarcodes = True,
	.Speed = ReadingSpeed.Balanced
}

' Read barcode from TIF image
Private results As BarcodeResults = BarcodeReader.Read("sample.tif", options)

' Output the barcodes value to console
For Each result In results
	Console.WriteLine(result.Value)
Next result
$vbLabelText   $csharpLabel

In the code snippet, we not only set BarcodeReaderOptions properties, but we also apply some filters, specifically the SharpenFilter and ContrastFilter. These filters essentially help in improving the clarity of blurry images for barcode detection and reading. You can find more information on image correction filters in the 'How to use Image Correction Filters' article.

For the BarcodeReaderOptions object, we suggest that users include ExpectMultipleBarcodes for IronBarcode to scan all available barcodes in the image file, Speed to balance between the reading accuracy and performance, ExpectBarcodeTypes to further increase performance, and ImageFilters to apply the filters set in ImageFilterCollection for reading accuracy.

Though setting the BarcodeReaderOptions object is optional for most use cases, it is important for users to get the most out of IronBarcode when reading barcodes from multipage GIF and TIFF image files.

Preguntas Frecuentes

¿Cómo puedo leer códigos de barras de archivos GIF y TIFF de varias páginas en C#?

Puedes usar IronBarcode para leer códigos de barras de archivos GIF y TIFF de varias páginas utilizando el método BarcodeReader.Read. Simplemente pasa el archivo de imagen al método e IronBarcode procesará las imágenes de varias páginas o varios marcos sin problemas.

¿Cuáles son los beneficios de usar IronBarcode para leer archivos de imagen de varias páginas?

IronBarcode simplifica el proceso de lectura de archivos de imagen de varias páginas al aceptarlos directamente sin requerir la separación manual de marcos o páginas. También ofrece opciones avanzadas como filtros de imagen y BarcodeReaderOptions para mejorar la precisión de la lectura.

¿Puedo usar filtros de imagen para mejorar la precisión de la lectura de códigos de barras en IronBarcode?

Sí, puedes aplicar filtros de imagen como Grayscale, SharpenFilter y ContrastFilter en IronBarcode para mejorar la claridad de la imagen y la precisión de la lectura de códigos de barras.

¿Es posible leer múltiples códigos de barras en una sola imagen usando IronBarcode?

Sí, IronBarcode puede detectar múltiples códigos de barras en una sola imagen activando la opción ExpectMultipleBarcodes dentro de la clase BarcodeReaderOptions.

¿Cómo convierto imágenes a TIFF o GIF de varias páginas en C#?

Puedes convertir imágenes a formatos TIFF o GIF de varias páginas usando la biblioteca IronDrawing. Importa imágenes en una lista de objetos AnyBitmap y usa los métodos AnyBitmap.CreateMultiFrameTiff o AnyBitmap.CreateMultiFrameGif.

¿Cuál es la diferencia entre los formatos GIF y TIFF de varias páginas?

Los GIFs de varias páginas utilizan compresión sin pérdida y admiten animaciones simples pero están limitados a 256 colores. Los TIFFs de varias páginas admiten varios métodos de compresión, mayores profundidades de color y opciones de transparencia, pero no están diseñados para animaciones.

¿Necesito preprocesar las imágenes antes de leer códigos de barras con IronBarcode?

No se requiere preprocesamiento. IronBarcode puede manejar y leer archivos de imagen de varias páginas directamente sin necesidad de ninguna preparación manual.

¿Cómo se pueden aplicar técnicas avanzadas de lectura de códigos de barras utilizando IronBarcode?

La lectura avanzada de códigos de barras en IronBarcode se puede lograr configurando la clase BarcodeReaderOptions. Se pueden establecer opciones como ExpectMultipleBarcodes, Speed y ImageFilters para optimizar el rendimiento y la precisión.

Hairil Hasyimi Bin Omar
Ingeniero de Software
Como todos los grandes ingenieros, Hairil es un ávido aprendiz. Está refinando su conocimiento de C#, Python y Java, usando ese conocimiento para agregar valor a los miembros del equipo en Iron Software. Hairil se unió al equipo de Iron Software desde la Universiti Teknologi MARA en Malasia, donde se ...
Leer más
¿Listo para empezar?
Nuget Descargas 1,935,276 | Versión: 2025.11 recién lanzado