How to set DPI Setting in OCR

Dots Per Inch (DPI) is a fundamental measurement of image quality, determining the level of detail present in a scanned document or digital photograph. While scanning documents is a fast and efficient way to digitize physical records, the process can often result in low-resolution files, especially when using default or "quick scan" settings. This lack of detail makes the text appear blurry or pixelated, presenting a significant obstacle for data extraction.

This is where OCR performance is directly impacted. OCR engines function by analyzing the precise shapes and patterns of characters to convert them into machine-readable text. When an image has a low DPI, there aren't enough pixels to clearly define each letter, causing fine details to be lost and leading to inaccurate results. However, IronOCR is engineered to overcome these common challenges. It has been finely tuned to achieve high accuracy on scans with resolutions as low as 225 DPI.

Get started with IronOCR

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

First Step:
green arrow pointer


DPI Setting Example

This example uses a sample image with a low resolution of approximately 100 DPI and adds artificial noise to demonstrate the effectiveness of the TargetDPI feature.

The actual text in the image is: "Testing testing testing blurry text example example example".

Blurry Text Image

Code Example

In this example, we'll set the TargetDPI to 300 to upscale the image resolution to 300 DPI. Afterward, we'll load the input image from above and print out the extracted test with Text and the confidence level with Confidence.

:path=/static-assets/ocr/content-code-examples/how-to/dpi-setting.cs
using IronOcr;
using System;

var ocrTesseract = new IronTesseract();

using var ocrInput = new OcrInput();
// Set the target DPI to 300 for better OCR accuracy
ocrInput.TargetDPI = 300;

ocrInput.LoadImage(@"images\image.png");

// Perform OCR on the image with the specified DPI
var ocrResult = ocrTesseract.Read(ocrInput);
// Display the text extracted from the image
Console.WriteLine(ocrResult.Text);
// Display the confidence level of the OCR result
Console.WriteLine(ocrResult.Confidence);
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Output

Text Output

As the output shows, IronOCR achieves an 85% confidence score. Despite the significant noise and low initial DPI of the source image, the result is exceptionally accurate, demonstrating the power of the upscaling feature.

IronOCR includes built-in capabilities that can automatically enhance low-resolution images by upscaling them, all within a single library.

DPI Setting Comparison

To illustrate the difference, here is the result of processing the same low-resolution image without setting the TargetDPI property.

Finding the correct DPI is a balance. High DPI is more accurate but slower; low DPI is faster but less reliable. When in doubt, let Iron Tesseract's automatic preprocessing determine the optimal settings. You can also disable the automatic upscaling by setting the TargetDPI property to 0 .

Output

Text Output

Without upscaling, the confidence score drops to 79%, and the extracted text is significantly less accurate. This comparison clearly highlights how setting a TargetDPI can dramatically improve OCR results on low-quality images.

DPI Setting for PDF

When processing a PDF, IronOCR will upscale the entire document to the target DPI, not just the images contained within it.

While a higher DPI can often lead to better OCR results, the optimal setting can vary significantly between different PDFs. Suppose you are unsure which value to use. In that case, it is best to leave the DPI at its default setting and allow IronOCR to determine the best configuration for your document automatically.

Warning The maximum value for TargetDPI is 32,766. Setting a DPI higher than this limit will cause an exception. This happens because the resulting image dimensions would exceed Tesseract's maximum supported size of 32,767 x 32,767 pixels. If the limit is exceeded, you will receive the following error message: 'TargetDPI is too high and would result in an image too large ({new_width} x {new_height}) for Tesseract. The maximum image size for Tesseract is 32767 x 32767'

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...Read More

Ready to Get Started?
Nuget Downloads 4,685,233 | Version: 2025.10 just released