How to Read Multi-Frame/Page GIFs and TIFFs

by Chaknith Bin

TIFF(Tagged Image File Format) is a popular format for high-quality images. It supports lossless compression, making it suitable for images that need to maintain their original quality, such as scanned documents or professional photography.

GIF(Graphics Interchange Format) is a format primarily used for simple, web-friendly images and animations. GIF supports both lossless and lossy compression. It's known for its ability to include animations in a single file, making it popular for short, looping animations often seen on websites and in messaging apps.

IronOCR provides the capability to read both single and multiple frame/page GIFs and TIFFs. Simply import the image file using one of our methods, and the method will do the rest.

Get started with IronOCR

Start using IronOCR in your project today with a free trial.

First Step:
green arrow pointer



Read a Single/Multi-Frame TIFF Example

To perform OCR, first instantiate the IronTesseract class. Utilize the 'using' statement to create the OcrImageInput object. This constructor supports both single-frame and multi-frame TIFF and TIF formats. Finally, apply the Read method to perform OCR on the imported TIFF file.

:path=/static-assets/ocr/content-code-examples/how-to/input-tiff-gif-read-tiff.cs
using IronOcr;

// Instantiate IronTesseract
IronTesseract ocrTesseract = new IronTesseract();

// Import TIFF/TIF
using var imageInput = new OcrImageInput("Potter.tiff");
// Perform OCR
OcrResult ocrResult = ocrTesseract.Read(imageInput);
Imports IronOcr

' Instantiate IronTesseract
Private ocrTesseract As New IronTesseract()

' Import TIFF/TIF
Private imageInput = New OcrImageInput("Potter.tiff")
' Perform OCR
Private ocrResult As OcrResult = ocrTesseract.Read(imageInput)
VB   C#
Read TIFF image

Read GIF Example

Similarly, simply specify the GIF file path while constructing the OcrImageInput class. The constructor will handle all the necessary steps to import the image.

:path=/static-assets/ocr/content-code-examples/how-to/input-tiff-gif-read-gif.cs
using IronOcr;

// Instantiate IronTesseract
IronTesseract ocrTesseract = new IronTesseract();

// Import GIF
using var imageInput = new OcrImageInput("Potter.gif");
// Perform OCR
OcrResult ocrResult = ocrTesseract.Read(imageInput);
Imports IronOcr

' Instantiate IronTesseract
Private ocrTesseract As New IronTesseract()

' Import GIF
Private imageInput = New OcrImageInput("Potter.gif")
' Perform OCR
Private ocrResult As OcrResult = ocrTesseract.Read(imageInput)
VB   C#

Specify Scan Region

You can include a CropRectangle object when constructing the OcrImageInput class, allowing you to define a specific area within the image document for OCR. This can greatly enhance performance, especially for large image documents.

:path=/static-assets/ocr/content-code-examples/how-to/input-images-read-specific-region.cs
using IronOcr;
using IronSoftware.Drawing;
using System;

// Instantiate IronTesseract
IronTesseract ocrTesseract = new IronTesseract();

// Specify crop region
Rectangle scanRegion = new Rectangle(800, 200, 900, 400);

// Add image
using var imageInput = new OcrImageInput("Potter.tiff", ContentArea: scanRegion);
// Perform OCR
OcrResult ocrResult = ocrTesseract.Read(imageInput);

// Output the result to console
Console.WriteLine(ocrResult.Text);
Imports IronOcr
Imports IronSoftware.Drawing
Imports System

' Instantiate IronTesseract
Private ocrTesseract As New IronTesseract()

' Specify crop region
Private scanRegion As New Rectangle(800, 200, 900, 400)

' Add image
Private imageInput = New OcrImageInput("Potter.tiff", ContentArea:= scanRegion)
' Perform OCR
Private ocrResult As OcrResult = ocrTesseract.Read(imageInput)

' Output the result to console
Console.WriteLine(ocrResult.Text)
VB   C#

OCR Result

Read specific region
Chaknith related to OCR Result

Chaknith Bin

Software Engineer

Chaknith is the Sherlock Holmes of developers. It first occurred to him he might have a future in software engineering, when he was doing code challenges for fun. His focus is on IronXL and IronBarcode, but he takes pride in helping customers with every product. Chaknith leverages his knowledge from talking directly with customers, to help further improve the products themselves. His anecdotal feedback goes beyond Jira tickets and supports product development, documentation and marketing, to improve customer’s overall experience.When he isn’t in the office, he can be found learning about machine learning, coding and hiking.