OCR Preprocessing API: Detect and Unskew a Photo of a Document with JavaScript

Photos taken with cell phone cameras are prone to becoming skewed. That isn’t a big deal –unless you’re thinking of performing an OCR operation on that photo, or trying to convert it into a PDF. To accomplish either of those operations quickly and cleanly, you should take advantage of our Unskew OCR Preprocessing API, which will turn a skewed image into a perfectly square image. You can then perform OCR directly on the photo or convert to PDF first and then use that document in a suitable OCR operation instead.

Connecting to this API is easy — below, we’ve provided instructions to include ready-to-run code snippets for structuring your API call with JavaScript. On the Cloudmersive API Console page, you’ll find similar code snippets available in a dozen of the most commonly used programming languages.

Let’s start by installing the jQuery library, which we can do by running the below command:

bower install jquery

Then we can add in a code snippet which will capture the image file for the operation:

var form = new FormData();
form.append("imageFile", fileInput.files[0], "file");

Now there’s only one step left — add in the below code for the API call, and you’re all done:

var settings = {
"url": "https://api.cloudmersive.com/ocr/preprocessing/image/unskew",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "multipart/form-data",
"processData": false,
"mimeType": "multipart/form-data",
"contentType": false,
"data": form
$.ajax(settings).done(function (response) {

You’ll need to include your Cloudmersive API key where indicated in the code above. To get a key, head to our website (Home — Cloudmersive APIs) and create a free account. With your free account, you’ll get a limit of 800 API calls per month, with access to dozens of similar Cloudmersive utility APIs.




There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

What is python language and What are its boundaries

Jenkins on Kubernetes: From Zero to Hero

Did you know that the term debugging was inspired by a real insect?

Pair Programming

Founder story: my journey towards building a confidential cloud

Get Email notification on AWS IAM user creation

Configuring Kubernetes Multinode cluster Over AWS Cloud manually

Introduction to Redis Streams

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

More from Medium

OCR Preprocessing API: Get the Angle of the Page, Document or Receipt for an OCR Conversion

How to Install KeyCloak 17 on Windows Machine

SonarQube — The Key To The Art Of Zen

OJET — Proxy to Backend REST API Server