Skip to main content
POST
Document Crop & Enhance

Authorizations

x-ti-app-id
string
header
required

Please Sign in to TextIn and navigate to "Console - API Keys" to view x-ti-app-id

x-ti-secret-code
string
header
required

Please Sign in to TextIn and navigate to "Console - API Keys" to view x-ti-secret-code

Query Parameters

enhance_mode
enum<integer>
default:-1

Image enhancement mode.

  • 1: Brighten
  • 2: Enhance and sharpen
  • 3: Black and white
  • 4: Grayscale
  • 5: Shadow removal and enhancement
  • 6: Bitmap (dithered)
  • -1: Disable enhancement (default)
Available options:
-1,
1,
2,
3,
4,
5,
6
Example:

-1

crop_image
enum<integer>
default:1

Whether to perform cropping.

  • 0: Do not crop
  • 1: Crop (default)
Available options:
0,
1
Example:

1

only_position
enum<integer>
default:0

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
Available options:
0,
1
Example:

0

dewarp_image
enum<integer>
default:1

Whether to perform distortion correction (dewarp).

  • 0: Do not correct
  • 1: Correct (default)
Available options:
0,
1
Example:

1

deblur_image
enum<integer>
default:0

Whether to perform sharpness enhancement (deblur).

  • 0: Do not enhance sharpness (default)
  • 1: Enhance sharpness
Available options:
0,
1
Example:

0

correct_direction
enum<integer>
default:0

Whether to correct the image orientation.

  • 0: Do not correct orientation (default)
  • 1: Correct orientation
Available options:
0,
1
Example:

0

round_image
enum<integer>
default:0

Whether to return a rounded-corner crop.

  • 0: Do not return a rounded-corner crop (default)
  • 1: Return a rounded-corner crop result
Available options:
0,
1
Example:

0

jpeg_quality
integer
default:95

Compression quality of the cropped image. Recommended range 65-100. Defaults to 95 when not set.

Example:

95

size_and_positon
string

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 to 0 to 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.

Example:

"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

200 - application/json

Response result

code
integer
required

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
Example:

200

message
string
required

Response message

Example:

"success"

x_request_id
string
required

Unique identifier of the request. Present in every response.

Example:

"7596b8c9d2ddbc9924b66651e9efc174"

msg
string

Response message (duplicate of message)

Example:

"success"

version
string

API version number

Example:

"v2.0.8"

duration
number

Processing time, in milliseconds (ms)

Example:

100

result
object