Test in a live environment
Test in production without watermarks.
Works wherever you need it to.
In the current digital era, transforming image-based content into easy-to-read editable, searchable text. This is particularly important in scenarios like archiving paper-based documents, extracting key information from images, or digitizing handwritten or printed materials. Optical Character Recognition (OCR) technology offers a solution to automate this conversion process. One highly reliable and efficient tool to achieve this is IronOCR, a robust OCR library for .NET.
This article will explain how to convert a picture to text using IronOCR, and explore how this conversion can save time, reduce errors, and streamline processes like data extraction, archiving, and document processing.
There are many reasons why you might want to convert an image into text, including:
Before we explore how IronOCR's powerful image-to-text capabilities can be leveraged to extract text from images, let's first take a look at the general step-by-step process using an online tool, docsumo. Online OCR tools are a helpful option for those looking to do casual, or even one-off, OCR tasks, thanks to their lack of needing any manual setup. Of course, if you need to perform OCR tasks regularly, then having a powerful OCR tool such as IronOCR could work better for you.
To begin utilizing OCR technology to extract text from image files, we first navigate to the online image OCR tool we want to use.
Now, by clicking the "Upload File" button, we can upload the image file from which we want to extract text. The tool will immediately begin to process the image.
Now that the image has finished being processed, we can download the extracted text as a new Text document, for further use or manipulation.
You can also view the file, highlighting the various sections to view the text contained within it. This could be particularly helpful if you just want to view the text within certain sections. Then, you can still go on to download the text as a Text document, XLS, or JSON.
IronOCR is a versatile .NET library that allows you to perform OCR operations on images. With a wide range of features to offer, it can process various file formats (such as PNG, JPEG, TIFF, and PDF), perform image correction, scan specialist documents (Passports, license plates, etc), provide advanced information about the scanned files, convert scanned documents, and highlight text.
Before you can start reading images using IronOCR, you will need to install it if you do not already have it installed in your project. You can easily install IronOCR using NuGet in Visual Studio. Open the NuGet Package Manager Console and run the following command:
Install-Package IronOcr
Install-Package IronOcr
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'Install-Package IronOcr
Alternatively, you can install IronOCR via the NuGet Package Manager for Solution page by searching for IronOCR.
To use IronOCR in your code, be sure to have the proper import statement at the top of your code:
using IronOcr;
using IronOcr;
Imports IronOcr
To start with, let's take a look at a basic image-to-text example using IronOCR. This is a core functionality of any OCR tool, and for this example, we will be using the PNG file we used for the online tool. In this example, we have first instantiated the IronTesseract class and assigned it the variable 'ocr'. We then use the OcrImageInput class to create a new OcrImageInput object from the image file provided. Finally, the Read** method is used to read the text from the image and returns an [OcrResult](/csharp/ocr/object-reference/api/IronOcr.OcrResult.html) object. We can then access the extracted text and display it to the console using [ocrResult.Text**](/csharp/ocr/object-reference/api/IronOcr.OcrResult.html#IronOcr_OcrResult_Text).
using IronOcr;
IronTesseract ocr = new IronTesseract();
using OcrImageInput image = new OcrImageInput("example.png");
OcrResult ocrResult = ocr.Read(image);
Console.WriteLine(ocrResult.Text);
using IronOcr;
IronTesseract ocr = new IronTesseract();
using OcrImageInput image = new OcrImageInput("example.png");
OcrResult ocrResult = ocr.Read(image);
Console.WriteLine(ocrResult.Text);
Imports IronOcr
Private ocr As New IronTesseract()
Private OcrImageInput As using
Private ocrResult As OcrResult = ocr.Read(image)
Console.WriteLine(ocrResult.Text)
IronOCR supports multiple image formats like PNG, JPEG, BMP, GIF, and TIFF. The process to read text from different image formats remains the same, you just need to load the file with the correct extension.
using IronOcr;
IronTesseract ocr = new IronTesseract();
using OcrImageInput image = new OcrImageInput("example.bmp");
OcrResult ocrResult = ocr.Read(image);
Console.WriteLine(ocrResult.Text);
using IronOcr;
IronTesseract ocr = new IronTesseract();
using OcrImageInput image = new OcrImageInput("example.bmp");
OcrResult ocrResult = ocr.Read(image);
Console.WriteLine(ocrResult.Text);
Imports IronOcr
Private ocr As New IronTesseract()
Private OcrImageInput As using
Private ocrResult As OcrResult = ocr.Read(image)
Console.WriteLine(ocrResult.Text)
OCR performance can be improved by optimizing the image and configuring options such as language, image resolution, and the level of noise in the image. Here’s how you can fine-tune OCR to increase the accuracy of text extraction on an image whose quality needs improving through the use of the DeNoise() and Sharpen() methods:
using IronOcr
IronTesseract ocr = new IronTesseract();
using OcrImageInput image = new OcrImageInput("example.png");
image.DeNoise();
image.Sharpen();
OcrResult ocrResult = ocr.Read(image);
Console.WriteLine(ocrResult.Text);
using IronOcr
IronTesseract ocr = new IronTesseract();
using OcrImageInput image = new OcrImageInput("example.png");
image.DeNoise();
image.Sharpen();
OcrResult ocrResult = ocr.Read(image);
Console.WriteLine(ocrResult.Text);
Using IronOcr IronTesseract ocr = New IronTesseract()
Using image As New OcrImageInput("example.png")
image.DeNoise()
image.Sharpen()
Dim ocrResult As OcrResult = ocr.Read(image)
Console.WriteLine(ocrResult.Text)
End Using
End Using
Now that we know the basics of the image-to-text process, let's now look at how we can export the resulting text for later use. For this example, we will use the same process as before to load the image and scan it. Then, using File.WriteAllText("output.txt", ocrResult.Text), we create a new text file called 'output.txt' and save the extracted text to the file.
using IronOcr;
IronTesseract ocr = new IronTesseract();
using OcrImageInput image = new OcrImageInput("example.png");
OcrResult ocrResult = ocr.Read(image);
File.WriteAllText("output.txt", ocrResult.Text);
using IronOcr;
IronTesseract ocr = new IronTesseract();
using OcrImageInput image = new OcrImageInput("example.png");
OcrResult ocrResult = ocr.Read(image);
File.WriteAllText("output.txt", ocrResult.Text);
Imports IronOcr
Private ocr As New IronTesseract()
Private OcrImageInput As using
Private ocrResult As OcrResult = ocr.Read(image)
File.WriteAllText("output.txt", ocrResult.Text)
Converting text from an image using IronOCR is a fast, accurate, and efficient way to handle document processing tasks. Whether you are working with scanned documents, digital images, or PDF documents, IronOCR simplifies the process, providing high accuracy, multi-language support, and powerful image processing tools. This tool is ideal for businesses looking to streamline their document management workflows, automate data extraction, or enhance accessibility.
Use the free trial to try out IronOCR's powerful features for yourself today, it only takes a few minutes to get it fully working within your workspace so you can begin processing OCR tasks within no time!
9 .NET API products for your office documents