AI Straighten Crop API
Straighten tilted photos with full-image AI tilt prediction through the Retouch4me Cloud API.
Use AutoStraightenMode: "AI" when the image itself is tilted and you want the Crop plugin to estimate the horizon/overall image angle. This is different from AutoStraightenMode: "Person", which is for pose/person alignment and document portrait crops.
This example uses a tilted Eiffel Tower source image. The Cloud API returned a ready straightened JPEG and metadata with Angle: 2.4963886737823486 and RotInvariant: 0.0014716327423229814.
Choose the output mode by what your integration needs: Layer: 0 with outputFormat: "jpeg" returns the finished straightened image. Layer: 1 with outputFormat: "zip" returns metadata in result.json, including the predicted angle.
Ready Image Output
Use this request when your application needs a finished JPEG. The API straightens the source image, applies AutoMode: "Maximum" to keep the largest valid crop after rotation, and returns the flattened image from /retoucher/getFile/{id}.
{
"mode": "professional",
"outputFormat": "jpeg",
"tasks": [
{
"Plugin": "Crop",
"Layer": 0,
"User Params": {
"AutoMode": "Maximum",
"AutoStraightenMode": "AI",
"AspectRatio": "Original"
}
}
]
}
AutoStraightenMode: "AI". Download AI straightened JPEGAngle Metadata Output
Use this request when your application needs the prediction data instead of a finished image. The API returns a ZIP archive. Inside it, result.json contains AI predicted.Angle and AI predicted.RotInvariant.
The angle is useful when you want to inspect, log, or apply the rotation in your own pipeline. Download the live example metadata ZIP or the extracted full result.json. For AI Straighten integrations, read the AI predicted block from the Crop plugin entry.
{
"mode": "professional",
"outputFormat": "zip",
"tasks": [
{
"Plugin": "Crop",
"Layer": 1,
"User Params": {
"AutoMode": "Maximum",
"AutoStraightenMode": "AI",
"AspectRatio": "Original"
}
}
]
}
| Field | Meaning |
|---|---|
AI predicted.Angle | The predicted straighten angle in degrees for the source image. |
AI predicted.RotInvariant | Internal confidence/rotation-invariant prediction value returned by the Crop model. |
Show AI Straighten angle excerpt from result.json
{
"jsonVersion": "1",
"plugins": [
{
"AI predicted": {
"Angle": 2.4963886737823486,
"RotInvariant": 0.0014716327423229814
},
"operationIndex": 0,
"pluginName": "Crop"
}
]
}
Related Crop Guides
For person-aware straightening and portrait framing, see Pose Crop. For passport and ID photo framing, see Passport and ID Photo Crop API. For manual geometry, use the Crop manual playground.