Convert images with optical character recognition
Leave feedback
On this page
About image file formats
An image file format is a standard method for organizing and storing images on devices like computers, tablets and smartphones. Digital images store image data in a 2-dimensional grid of pixels where each pixel is a representation of color in terms of a number of bits. Image file types are classified into vector image formats and raster image formats. 3D Images are another type of vector image file format that is used for managing 3D images.
Raster formats
Raster Graphics are digital images that comprise of pixels data for the representation of colors. These are the most common image types for graphics used for the web as well as digital photos. Some of the raster images can be compressed to reduce image file size. Common raster image file extensions and their file formats include BMP (Bitmap image file), PNG (Portable Network Graphics) and GIF (Graphics Interchange File).
Vector formats
Vector images are defined by 2D points, instead of pixels, which are connected to give a geometric shape to the image. The points have properties that define the direction of paths, color, shape, curve, thickness, and fill. Common vector image file extensions and their file formats include SVG (Scalable Vector Graphics), EPS (Encapsulated PostScript language) and PDF (Portable Document Format).
To allow OCR conversions GroupDocs.Conversion provides an extension point to offload the actual OCR process to the OCR processing library, but at the same time gives you the simplicity of conversion setup. The extension point is the IOcrConnector interface.
First, you must decide which OCR processing library will use. Different libraries have different setup processes.
In our example, we will use Aspose.OCR. Install the Aspose.OCR nuget package in your project. Then implement IOcrConnector. The following code snippet provides a sample implementation:
Once the IOcrConnector interface is implemented, the JPG to DOCX conversion code snippet looks like this:
With v24.10 and later:
// Load the source JPG fileRasterImageLoadOptionsloadOptions=newRasterImageLoadOptions();loadOptions.SetOcrConnector(newOcrConnector());using(Converterconverter=newConverter("sample.jpg",(LoadContextloadContext)=>loadOptions)){// Set the convert options for DOCX formatWordProcessingConvertOptionsoptions=newWordProcessingConvertOptions();// Convert to DOCX formatconverter.Convert("converted.docx",options);}
Before v24.10:
// Load the source JPG fileImageLoadOptionsloadOptions=newImageLoadOptions();loadOptions.SetOcrConnector(newOcrConnector());using(Converterconverter=newConverter("sample.jpg",()=>loadOptions)){// Set the convert options for DOCX formatWordProcessingConvertOptionsoptions=newWordProcessingConvertOptions();// Convert to DOCX formatconverter.Convert("converted.docx",options);}
Put it simply - you install an OCR processing library, implement the IOcrConnector interface, load an image file into the Converter class providing the IOcrConnector instance, select the desired output format and GroupDocs.Conversion does all the rest.
Note
Refer to the API reference for more conversion options and customizations.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.