apyhub
Back

Detect Image Rotation API

What it does

Detect Image Rotation API checks whether a product photo is upright and tells you exactly how far to rotate it if it isn't. Upload an image in the file field and get back a JSON response with wasAlreadyUpright, the clockwise quarter-turn fix in rotationClockwise4Axis (0, 90, 180 or 270), the precise fix including fine tilt in rotationClockwiseFull, and a confidence score from 0 to 1 for each. The service supports JPEG, PNG, WebP, GIF, TIFF, AVIF and HEIC (iPhone) photos, with no minimum or maximum resolution.

Use it when uploaded product photos need an orientation check before they are shown to shoppers, added to a catalog, or passed into AI vision, background removal, or OCR steps that perform worse on rotated input. It works best on packaged goods with visible text or labels and on products with a clear shape, such as bottles and boxes. Keep the product roughly centered, because the service analyzes a centered crop of the image.

Results are based on the image pixels, not the EXIF orientation tag. When the result isn't reliable enough to apply automatically, resolved is false and note carries a short message saying why, so you can send the photo to a person instead. When the camera tag disagrees with the image content, resolved is also false, note says so, and exifOnlyRemainder shows how many degrees would still be off if you rotated by the tag alone. Hand-held products, symmetric objects, and flat-lay shots are harder to call and are more likely to come back unresolved.

If you are building a marketplace upload flow, catalog ingestion job, or image moderation queue, Product Photo Rotation Detector gives you a clear rotate, skip, or review decision for every photo without training your own model.

POST
Detect photo rotation
https://api.eu.apyhub.com/blueveta/detect-image-rotation-api/api/upright

QUICKSTART

GUIDE

Quickstart

Upload a product photo to check whether it's upright and how far to rotate it.

curl -X POST "https://api.eu.apyhub.com/blueveta/detect-image-rotation-api/api/upright" \
  -H "apy-token: $APY_TOKEN" \
  -F "file=@/path/to/photo.jpg"

What you'll get back

Returns a JSON object with the clockwise rotation needed and a confidence score for each answer. rotationClockwise4Axis is the quarter-turn fix (0, 90, 180 or 270), rotationClockwiseFull adds any fine tilt, and resolved is false when the photo should be reviewed by a person. note is null unless there's something to flag, such as a low-confidence or EXIF-mismatch warning.

{
  "ok": true,
  "wasAlreadyUpright": false,
  "rotationClockwise4Axis": 90,
  "confidence4Axis": 0.94,
  "rotationClockwiseFull": 93,
  "confidenceFull": 0.86,
  "exifOnlyRemainder": null,
  "resolved": true,
  "note": null,
  "heicConverted": false,
  "latencyMs": 480
}
TRY ITLIVE · 1 ATOM
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
Max 100MB total per request (all files combined). Larger? Use this API's URL-based endpoint instead, if it has one.
body*
The product photo to analyze. JPEG, PNG, WebP or HEIC. Keep the product roughly centered.

About this endpoint

What it does

Uploads a product photo and returns the clockwise rotation needed to make it upright, with a confidence score for each answer. The response gives the quarter-turn fix in rotationClockwise4Axis and the precise fix including fine tilt in rotationClockwiseFull. It also flags photos that should be reviewed by a person and photos whose EXIF orientation tag disagrees with the image content.

Use it to check uploads before they reach shoppers or downstream image processing. Rotation values are always clockwise and are based on the image pixels, not the EXIF tag. Rotating by rotationClockwise4Axis is lossless; correcting fine tilt with rotationClockwiseFull requires resampling.

Request Body

ParameterTypeMandatoryDescription
fileStringYesThe product photo to analyze. Supported formats: JPEG, PNG, WebP, GIF, TIFF, AVIF and HEIC (iPhone). The format is detected from the file content, not the file name. No minimum or maximum resolution. Keep the product roughly centered, as the service analyzes a centered crop.

Response

Returns a JSON object with the rotation needed, a confidence score for each answer, and a resolved flag that tells you whether the result is safe to apply automatically. exifOnlyRemainder and note are null when there's nothing to report. When resolved is false, note explains why.

ParameterTypeMandatoryDescription
okBooleanYestrue when the image was analyzed successfully.
wasAlreadyUprightBooleanYestrue when the photo is already upright and needs no rotation.
rotationClockwise4AxisENUMYesClockwise rotation needed, as a quarter turn. Allowed values: 0, 90, 180, 270.
confidence4AxisNumberYesConfidence in rotationClockwise4Axis, from 0 to 1.
rotationClockwiseFullNumberYesComplete clockwise rotation needed in degrees, including fine tilt, from 0 to 360.
confidenceFullNumberYesConfidence in rotationClockwiseFull, from 0 to 1. Always lower than or equal to confidence4Axis, because fine tilt is harder to measure.
exifOnlyRemainderNumberNoSigned degrees still needed if you rotate by the EXIF orientation tag alone. Positive is clockwise, negative is counter-clockwise. null when the photo has no EXIF tag that implies a rotation.
resolvedBooleanYesfalse means the result should not be applied automatically and the photo should be reviewed by a person.
noteStringNoA short, plain-language message explaining why the result needs attention, or null when there's nothing to flag. It is returned when confidence is too low to apply the result automatically, or when the photo's EXIF orientation tag disagrees with the image content (the rotation values always follow the image content). In both cases resolved is false. Use resolved for logic; the message text is for display and may change.
heicConvertedBooleanNotrue when the input was a HEIC (iPhone) photo that was decoded before analysis.
latencyMsIntegerNoProcessing time in milliseconds.

Errors

Errors return HTTP 400 with ok: false and a code field.

CodeWhen it happens
multipart_no_file_partNo file was sent in the request.
empty_bodyThe uploaded file is empty (0 bytes).
unsupported_image_formatThe file is not a supported image format.
inference_failedThe image could not be read, for example a corrupt or truncated file.

Max 100MB total per request (all files combined). Larger? Use this API's URL-based endpoint instead, if it has one.

▣ COMMON ERRORS

Errors any endpoint can return

400bad_request

Required parameter missing or malformed body.

401unauthorized

API key missing, revoked, or not authorized for this service.

429rate_limited

Your plan's per-second rate exceeded. Retry with exponential backoff.

503upstream_busy

Backend temporarily unavailable. Try again in a few seconds.