What it does
Auto crop documents
Automatically detect the document boundary and crop away the surrounding background.The response also returns the four corner points of the detected document region, which can be used for downstream processing or visualization.Typical inputs include documents photographed on desks, receipts captured with extra background, and pages taken from imperfect distances or angles.
Correct perspective and orientation
Straighten document photos captured at an angle and correct geometric distortion so the page appears flat and rectangular.You can also enable orientation correction for sideways or incorrectly rotated document images.
Enhance document images
Apply optional image enhancements based on the source image and desired output.Available processing options include:
- Deblur
- Brighten
- Sharpen
- Black and white
- Grayscale
- Shadow removal
- Bitmap
Common use cases
The Document Crop & Enhance API can be used to prepare:- smartphone photos for OCR and text recognition;
- receipts, forms, contracts, and other paper documents for digital archiving;
- photographed pages for printing or copying;
- cleaner document images for sharing or display;
- document images before downstream parsing or data extraction.
Typical processing flow
A single request can combine the processing steps you need: Document photo → Auto crop → Perspective correction → Orientation correction → Enhance → Clean document image Each processing option can be enabled or disabled independently.Before you start
You need:- Your TextIn App ID and Secret Code. Find them in the TextIn console under API Keys, and send them in the
x-ti-app-idandx-ti-secret-coderequest headers. - A document image (jpg, png, bmp, webp, pdf, tiff, or single-frame gif).
For PDF input, only the first page is processed. Multi-page PDFs are accepted, but only the first page is cropped, corrected, and enhanced.
Set your credentials
Send a request
The endpoint accepts input in one of two ways. Send the raw file bytes withContent-Type: application/octet-stream, or send a file URL as plain text with Content-Type: text/plain.
The API always responds with HTTP 200. Check the
code field in the response body to determine success (200) or failure.- cURL
- Python
- Node.js
?correct_direction=1&enhance_mode=5. See Configuration for the full list.
Read the response
The response returns the processed image as a Base64-encoded JPG, plus dimensions and crop coordinates. Theimage value below is truncated for readability.
image field to save the processed image:
Next steps
Configuration
Control cropping, correction, and enhancement with query parameters.
API Reference
Every parameter, response field, and an interactive playground.
Supported Files & Limits
Supported formats, file size, and image dimensions.
Errors
Error codes and how to resolve them.

