This short tutorial guides on how to deskew scanned documents using Python REST API. You will learn to automatically straighten scanned image using Python Low Code API with the help of a Python-based Cloud SDK. It contains all the steps from loading the source image from the local file system to process and download the output from the Cloud.
Prerequisite
- Create an account API credentials to deskew an image
- Download Aspose.Imaging Cloud SDK for Python for correcting the image orientation
- Setup Python project with the above SDK
Steps to Straighten Scanned Image using Python Low Code API
- Commence the process by providing your Aspose Cloud credentials and the API base URL to authenticate and initialize the SDK client using ImagingApi
- Specify the filename of the skewed image and load it into a memory stream from the local system
- Upload the image to the cloud storage so Aspose API can access it
- Define options for deskewing
- Create a DeskewImageRequest with the uploaded filename and the above parameters and call DeskewImage()
- Save the deskewed image returned by the API to a local file
These steps have summarized the process to deskew photo using Python Low Code API. Commence the process by initializing the API client, uploading the skewed image, and creating the DeskewImageRequest object by filling in the required information. Subsequently, call the DeskewImage() method to straighten the image and save the response stream on the local file system as an image.
Code to Deskew Image Online using Python REST Interface
This code has demonstrated how to deskew photo using Python RESTful Service. We have set resizeProportionally as true to keep the image image’s aspect ratio after deskewing whereas seeing to false will result into stretching that may distort the image. Note that instead of writing the background color name, you may use the color code such as #FFFFFF.
This article has taught us the process to deskew an image. To convert a colored image to black and white, refer to the article on Convert Color Image to Black and White using Python REST API.