curl --request POST \
--url https://api.textin.ai/ai/service/v1/crop_enhance_image \
--header 'Content-Type: application/octet-stream' \
--header 'x-ti-app-id: <api-key>' \
--header 'x-ti-secret-code: <api-key>' \
--data '"<string>"'import requests
url = "https://api.textin.ai/ai/service/v1/crop_enhance_image"
payload = "<string>"
headers = {
"x-ti-app-id": "<api-key>",
"x-ti-secret-code": "<api-key>",
"Content-Type": "application/octet-stream"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-ti-app-id': '<api-key>',
'x-ti-secret-code': '<api-key>',
'Content-Type': 'application/octet-stream'
},
body: JSON.stringify('<string>')
};
fetch('https://api.textin.ai/ai/service/v1/crop_enhance_image', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.textin.ai/ai/service/v1/crop_enhance_image",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode('<string>'),
CURLOPT_HTTPHEADER => [
"Content-Type: application/octet-stream",
"x-ti-app-id: <api-key>",
"x-ti-secret-code: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.textin.ai/ai/service/v1/crop_enhance_image"
payload := strings.NewReader("\"<string>\"")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-ti-app-id", "<api-key>")
req.Header.Add("x-ti-secret-code", "<api-key>")
req.Header.Add("Content-Type", "application/octet-stream")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.textin.ai/ai/service/v1/crop_enhance_image")
.header("x-ti-app-id", "<api-key>")
.header("x-ti-secret-code", "<api-key>")
.header("Content-Type", "application/octet-stream")
.body("\"<string>\"")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.textin.ai/ai/service/v1/crop_enhance_image")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-ti-app-id"] = '<api-key>'
request["x-ti-secret-code"] = '<api-key>'
request["Content-Type"] = 'application/octet-stream'
request.body = "\"<string>\""
response = http.request(request)
puts response.read_body{
"code": 200,
"message": "success",
"msg": "success",
"version": "v2.0.8",
"duration": 100,
"x_request_id": "7596b8c9d2ddbc9924b66651e9efc174",
"result": {
"origin_width": 2000,
"origin_height": 3000,
"image_list": [
{
"cropped_width": 1500,
"cropped_height": 1800,
"image": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBD",
"position": [
0,
10,
500,
10,
500,
300,
0,
300
],
"angle": 90
}
]
}
}Document Crop & Enhance
Detect the document in a photo or scan, remove the background surrounding the document, correct geometric distortion, and enhance image quality.
Send the input in one of two ways:
Content-Type: application/octet-stream— the raw binary stream of a local file.Content-Type: text/plain— the URL of an online file (http and https are supported).
Supported formats: jpg, png, bmp, webp, pdf, tiff, single-frame gif. The file size must not exceed 50 MB, and the image width and height must both be between 20 and 10000 pixels. For PDF input, only the first page is processed.
curl --request POST \
--url https://api.textin.ai/ai/service/v1/crop_enhance_image \
--header 'Content-Type: application/octet-stream' \
--header 'x-ti-app-id: <api-key>' \
--header 'x-ti-secret-code: <api-key>' \
--data '"<string>"'import requests
url = "https://api.textin.ai/ai/service/v1/crop_enhance_image"
payload = "<string>"
headers = {
"x-ti-app-id": "<api-key>",
"x-ti-secret-code": "<api-key>",
"Content-Type": "application/octet-stream"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-ti-app-id': '<api-key>',
'x-ti-secret-code': '<api-key>',
'Content-Type': 'application/octet-stream'
},
body: JSON.stringify('<string>')
};
fetch('https://api.textin.ai/ai/service/v1/crop_enhance_image', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.textin.ai/ai/service/v1/crop_enhance_image",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode('<string>'),
CURLOPT_HTTPHEADER => [
"Content-Type: application/octet-stream",
"x-ti-app-id: <api-key>",
"x-ti-secret-code: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.textin.ai/ai/service/v1/crop_enhance_image"
payload := strings.NewReader("\"<string>\"")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-ti-app-id", "<api-key>")
req.Header.Add("x-ti-secret-code", "<api-key>")
req.Header.Add("Content-Type", "application/octet-stream")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.textin.ai/ai/service/v1/crop_enhance_image")
.header("x-ti-app-id", "<api-key>")
.header("x-ti-secret-code", "<api-key>")
.header("Content-Type", "application/octet-stream")
.body("\"<string>\"")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.textin.ai/ai/service/v1/crop_enhance_image")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-ti-app-id"] = '<api-key>'
request["x-ti-secret-code"] = '<api-key>'
request["Content-Type"] = 'application/octet-stream'
request.body = "\"<string>\""
response = http.request(request)
puts response.read_body{
"code": 200,
"message": "success",
"msg": "success",
"version": "v2.0.8",
"duration": 100,
"x_request_id": "7596b8c9d2ddbc9924b66651e9efc174",
"result": {
"origin_width": 2000,
"origin_height": 3000,
"image_list": [
{
"cropped_width": 1500,
"cropped_height": 1800,
"image": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBD",
"position": [
0,
10,
500,
10,
500,
300,
0,
300
],
"angle": 90
}
]
}
}Authorizations
Please Sign in to TextIn and navigate to "Console - API Keys" to view x-ti-app-id
Please Sign in to TextIn and navigate to "Console - API Keys" to view x-ti-secret-code
Query Parameters
Image enhancement mode.
1: Brighten2: Enhance and sharpen3: Black and white4: Grayscale5: Shadow removal and enhancement6: Bitmap (dithered)-1: Disable enhancement (default)
-1, 1, 2, 3, 4, 5, 6 -1
Whether to perform cropping.
0: Do not crop1: Crop (default)
0, 1 1
Whether to return only the crop corner points.
0: Return the corner points and the processed image (default)1: Return only the crop corner points, without the cropped result image
0, 1 0
Whether to perform distortion correction (dewarp).
0: Do not correct1: Correct (default)
0, 1 1
Whether to perform sharpness enhancement (deblur).
0: Do not enhance sharpness (default)1: Enhance sharpness
0, 1 0
Whether to correct the image orientation.
0: Do not correct orientation (default)1: Correct orientation
0, 1 0
Whether to return a rounded-corner crop.
0: Do not return a rounded-corner crop (default)1: Return a rounded-corner crop result
0, 1 0
Compression quality of the cropped image. Recommended range 65-100. Defaults to 95 when not set.
95
Client-supplied crop size and corner coordinates. When provided, the image is cropped according to these values.
Format: width,height,x1,y1,x2,y2,x3,y3,x4,y4
width,height: target image width and height. Set to0to use the default values.(x1, y1): top-left corner(x2, y2): top-right corner(x3, y3): bottom-right corner(x4, y4): bottom-left corner
Note: this parameter name is spelled size_and_positon in the API.
"0,0,0,10,500,10,500,300,0,300"
Body
The document image to process.
- With
Content-Type: application/octet-stream, the body is the raw binary stream of a local file (not FormData or any other wrapper). - With
Content-Type: text/plain, the body is plain text containing the URL of an online file.
Supported formats: jpg, png, bmp, webp, pdf, tiff, single-frame gif. Max size 50 MB; image width and height must be between 20 and 10000 pixels.
The body is of type file.
Response
Response result
Status code. See the response description for the full list of error codes.
- 200: Success
- 40101: x-ti-app-id or x-ti-secret-code is empty
- 40102: x-ti-app-id or x-ti-secret-code is invalid, authentication failed
- 40103: Client IP is not in the allowlist
- 40003: Insufficient balance, please recharge before using
- 40004: Parameter error, please check the technical documentation and verify the parameters
- 40007: The service does not exist or is not published
- 40008: The service is not enabled; enable it in the console before retrying
- 40301: Unsupported image type. The API returns the detected type, e.g., "Current file type is .gif"
- 40302: File size exceeds the 50 MB limit
- 40303: Unsupported file type
- 40304: Invalid image dimensions; width and height must be between 20 and 10,000 pixels
- 40305: No file uploaded
- 40306: QPS limit exceeded. Do not retry on this status code; continued requests may trigger IP rate limiting. Contact support to raise the limit.
- 40400: Invalid request URL, please check if the URL is correct
- 30203: Upstream service failure, please retry later
- 500: Internal server error
200
Response message
"success"
Unique identifier of the request. Present in every response.
"7596b8c9d2ddbc9924b66651e9efc174"
Response message (duplicate of message)
"success"
API version number
"v2.0.8"
Processing time, in milliseconds (ms)
100
Show child attributes
Show child attributes

