Convert Image to JSON using C#

Convert Image to JSON using C#

In the recent past, we have published a blog post that demonstrates the conversion process of image to text with OCR in C#. In this blog post, we will learn how to convert Image to JSON using C# programmatically in C#. We will use an enterprise-level .NET OCR API that offers methods and properties to configure the API calls that make image to JSON conversion efficient. This library also provides the methods to extract the text from a particular area of the image.

The following sections will be covered in this article:

.NET OCR - C# API installation

The installation procedure is simple, and you can install it without any third-party dependency. So, you can either download the DLL files or run the following command in the NuGet package manager to install this .NET OCR API.

Install-Package Aspose.OCR

How to Convert Image to JSON using C#

This OCR library can recognize scanned mages, screenshots, or any other image format. It lets you convert PDFs and images to text and JSON format.

Let’s write the following steps and the code snippet to convert an image to JSON in a .NET application using C#:

  1. Get the image URL.
  2. Initialize an instance of AsposeOcr.
  3. Create an object of RecognitionResult class and initialize it with the image recognition result.
  4. Instantiate an instance of RecognitionSettings class to customize the recognition process.
  5. Initialize the RecognizeImageFromUri method that recognizes text on the image provided by the URI link.
  6. Call the RecognitionText method to get the recognition result in one string.
  7. Invoke the GetJson method to form JSON string with recognition results.

The following sample code shows how to convert image to JSON in C#:

You can see the output JSON in the image below:

image to JSON conversion

Image to JSON Conversion in C# - Advanced Options

This .NET OCR API offers more than format conversion and processing options. There are many cases where you need to apply pre-processing provisions on the images for which this API provides methods and classes that you may find here.

Get a Free License

You may get a free temporary license to try the API beyond evaluation limitations.

Summing up

We are ending this blog post here with the hope that you have learned how to convert image to JSON in C# programmatically. Furthermore, you may visit documentation of this .NET OCR API to know about other features. Feel free to visit the GitHub repo to see the code examples with the descriptions. Finally, conholdate.com is writing new blog posts on new topics. Therefore, please stay in touch for regular updates.

Ask a question

You can let us know about your questions or queries on our forum.

FAQs

Can we change an image to JSON?

This .NET OCR API offers a stack of classes and the methods to convert image to JSON programmatically. In addition, you may visit the documentation.

How do you put an image file in a JSON object?

Call this RecognitionText method to transform the image into a string and then GetJson method will convert the string into JSON format programmatically.

See Also