ForHosting KIT · Images

Compute EXIF orientation fix

Find the exact correction for any EXIF orientation value from 1 to 8: orientation 6 means a 90-degree clockwise turn and no flip, while the mirrored values also get the right flip. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Orientation
6
You get
Rotation degrees
90
Operation order
flip_then_rotate

The EXIF Orientation tag tells software how stored image pixels must be transformed before they look upright. This capability turns any valid tag value from 1 through 8 into a clear, implementation-ready instruction: a clockwise rotation, horizontal or vertical flip flags, and the order in which to apply them. It handles ordinary camera rotations as well as the mirrored cases that are easy to implement incorrectly. Use the result in an image pipeline, thumbnail service, upload validator, or metadata inspection tool without maintaining your own orientation lookup table.

Why an upright photo can contain sideways pixels

Many cameras and phones avoid rearranging every pixel when a device is turned. Instead, they store the captured pixel grid in the sensor's convenient orientation and write an EXIF Orientation tag that tells a viewer how to present it. Software that honors the tag shows the photograph upright, while software that ignores it may show the same file sideways, upside down, or mirrored.

The tag uses eight defined values, not merely four rotation angles. Values 1, 3, 6, and 8 describe the familiar normal, half-turn, and quarter-turn cases. Values 2, 4, 5, and 7 include reflection, which is why treating orientation as rotation alone produces wrong output for some scanners, front-facing cameras, and edited files.

This capability accepts the numeric tag after it has been read from metadata and returns the exact display correction. It does not decode the image or alter pixels; it provides the small, reliable transform instruction that your image processor can apply.

How to apply the returned transform

Send one integer in the orientation field. The canonical mapping represents orientation 4 as a horizontal flip followed by a 180-degree rotation, which is geometrically equivalent to a vertical flip. Keeping one canonical reflection axis makes downstream code simpler while the explicit vertical flag keeps the response structure stable.

Orientation 1 returns zero rotation and no flip, making it safe to pass every image through the same decision step. Values outside 1 through 8, fractional numbers, numeric strings, missing fields, and other types return an invalid-input error instead of guessing.

Where the orientation lookup belongs in a pipeline

Use this calculation immediately after an EXIF parser reads the Orientation tag and before resizing, cropping, OCR, face detection, or thumbnail generation. Normalizing first means later coordinates refer to the upright display, avoiding crops that target the wrong edge or text recognition performed on sideways lines. If your decoder already performs automatic EXIF orientation, do not apply the returned transform a second time; either disable the decoder's automatic behavior or use this response only for inspection and planning.

After physically transforming pixels, most pipelines should write the output with Orientation 1 or remove the old orientation tag, because retaining the original tag may cause a compliant viewer to repeat the correction.

Normalize uploaded photographs

Translate each upload's Orientation tag into a transform before generating thumbnails, so every derivative has physically upright pixels.

Prepare scans for OCR

Correct rotated or mirrored scan pixels before text recognition, layout analysis, and coordinate-based extraction begin.

Test an image processing library

Compare the library's behavior for all eight EXIF values against a stable canonical rotation-and-flip mapping.

What values are accepted?

Only integer EXIF Orientation values from 1 through 8 are accepted.

Does this capability rotate the image itself?

No. It returns the transform needed to display stored pixels upright; your image processing library applies that transform.

Why are flip operations needed?

Four EXIF orientations include a reflection. A rotation alone cannot correctly represent mirrored orientations 2, 4, 5, and 7.

Should I flip or rotate first?

Flip first, then rotate clockwise. The order matters for orientations 5 and 7, because a reflection and a rotation do not give the same picture when you swap them.

What if my photo software already fixes orientation on its own?

Then do not apply the correction a second time, or the photo ends up turned twice. Either switch off the automatic step or use the result only to check what the file says.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/image/exif-orientation-fix

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/image/exif-orientation-fix \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"orientation":6}'
{
  "orientation": 6
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "image.exif_orientation_fix",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_mb15
max_megapixels12
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

How to apply the returned transform

The response repeats that value and returns rotation_degrees as 0, 90, 180, or 270, measured clockwise. It also returns flip_horizontal and flip_vertical Boolean flags. The operation_order value is flip_then_rotate, so an enabled flip is applied to the stored pixel grid before the clockwise rotation. That order matters for orientations 5 and 7 because reflection and rotation do not commute: reversing the operations can place the image in a different mirrored orientation.

Where the orientation lookup belongs in a pipeline

The capability is deterministic and uses no image data, network service, or device-specific heuristic, so the same tag always produces the same instruction in browser and API environments.

In what order should I apply a flip and rotation?

Apply the indicated flip to the stored pixels first, then rotate clockwise by rotation_degrees, as stated by operation_order.

What does it cost through the API?

Each API request costs $0.002. The computation is also suitable for the free browser runner because it requires no upload or network access.

Read the full KIT documentation →