JPG PNG Image to JSON C#

Images or graphics depict a lot of visual information that can contain text, pictures, graphs, etc. Sometimes you might want to convert some information from a JPG or PNG image to JSON format in order to process some data. In accordance with such requirements, this article covers how to convert an image to JSON by performing OCR operation programmatically in C#.

JPG or PNG Image to JSON Converter with OCR in C# – API Installation

You can extract any data or information from an image by performing OCR using Aspose.OCR for .NET API. You can easily access the API by downloading its DLL reference file from the Downloads page or with the following NuGet installation command:

PM> Install-Package Aspose.OCR

Convert Image to JSON with OCR Programmatically in C#

You can convert an image to JSON format with OCR in order to extract some data or information by following the steps below:

  1. Initialize an object of AsposeOcr class.
  2. Create an object of RecognitionResult class and recognize the image.
  3. Print the output JSON data.

The following code sample explains how to convert an image to JSON with OCR in C#:

Convert JPG or PNG Image to JSON with Image Corrections in C#

Some images may need to be processed prior to performing the optical character recognition techniques. Such processing can include the image corrections like specifying the auto-skew correction, threshold values, language, or other properties exposed by the RecognitionSettings class. Please follow the steps below for performing image corrections and then converting the image to JSON format:

  1. Create an object of the AsposeOcr class.
  2. Recognize the image while setting the image correction properties of RecognitionSettings class.
  3. Write the output result in JSON format.

The code below elaborates how to convert an image to JSON with image corrections in C#:

Get Free API License

You can request a free temporary license to test the API without any evaluation limitations.


In this article, you have explored how to convert a JPG or PNG image to JSON format with OCR programmatically in C#. It also explains how to perform some image corrections on the input image to enhance the accuracy level of the output JSON data. Furthermore, you can learn about other OCR features by visiting the documentation. In case of any concerns, please write to us at the forum.

See Also

Recognize Text with OCR on DjVu Image in C#