Rotate an image
A photo taken sideways, a scan that came out upside down, a batch of uploads where half the phones recorded orientation differently than the other half — this endpoint fixes it by rotating the image a quarter, half or three-quarter turn (90, 180 or 270 degrees) so the pixels sit the right way up everywhere.
This task is not available right now, so it cannot be purchased. Nothing is charged for it.
How it works & APIWhy images end up rotated wrong
Most phone cameras don't actually rotate the pixels when you turn the phone sideways to shoot; instead, they write an orientation flag into the image's EXIF metadata and expect the viewer to read it and rotate on display. That works fine in apps that respect EXIF, and fails badly in the many pipelines, thumbnail generators and older systems that ignore it, which is how a sideways photo ends up looking sideways everywhere except the phone that took it — and why baking the rotation into the pixels themselves fixes it for good.
What the endpoint does
You send the image to /image/rotate with the quarter-turn you need — 90, 180 or 270 degrees — and it returns a version with the pixels actually rotated, so the orientation is baked in and correct regardless of what the next system does or doesn't read from metadata. The request returns a task_id right away, the rotation happens asynchronously, and the result reaches you via signed webhook or a signed link valid for 24 hours.
Right-angle rotation, done losslessly
The common fixes are all quarter turns: 90 or 270 degrees puts a sideways photo upright, and 180 flips an upside-down scan back over. Because these are right-angle rotations, the pixel data is simply reordered — nothing is resampled or estimated, so there's no quality loss and the only change is that width and height swap on a 90 or 270 turn. Free-angle rotation to straighten a slightly tilted scan by a few degrees isn't part of this endpoint.
How it plugs into automation
Because it's a single asynchronous call, it belongs right after the upload step in any pipeline that ingests photos from unpredictable sources: user-submitted images, scanned paperwork, or camera feeds. Failed rotations retry automatically up to three times before returning a clear error, and a task that never completes is never billed, so a malformed file doesn't cost anything.
Who needs this
Document management systems correcting scanned pages, photo-sharing apps normalizing user uploads, and e-commerce platforms making sure product photos display upright regardless of how the seller's phone recorded them all lean on exactly this kind of correction.
What you can do with it
Sideways upload normalization
A photo-sharing app rotates sideways user uploads by 90 degrees to upright so thumbnails never render on their side.
Upside-down scan correction
A document management system rotates a batch of pages that came out of the scanner upside down back the right way with a 180-degree turn before running OCR.
Product photo normalization
An online marketplace rotates seller-submitted product photos to a consistent upright orientation before publishing listings.
Batch fix for legacy archives
An organization digitizing an old photo archive rotates a batch of scans that were fed into the scanner turned 90 or 180 degrees from upright.
FAQ
Can the rotate image API fix a sideways or upside-down photo?
Yes. You send the quarter-turn to apply — 90 or 270 degrees for a sideways photo, 180 for an upside-down one — and it rotates the actual pixels so the file displays correctly everywhere, not just in EXIF-aware viewers.
Can I rotate by a custom angle, not just 90 degrees?
No — rotation is by right angles only: 0, 90, 180 or 270 degrees. That covers sideways and upside-down photos and scans; straightening a scan that's tilted by a few degrees isn't supported here.
Is rotating images free?
The API is paid — each call draws from your prepaid ForHosting KIT balance: top up from $10.00 (it never expires), pay each request's published price, and a call with no balance returns HTTP 402. No subscription, no tokens, and a failed task is never charged.
What's the cost per image?
$0.002 per request plus $0.005 per image, and you're never charged for a task that fails.
Is rotation synchronous?
No, it's asynchronous. You receive a task_id immediately, and the rotated image arrives via signed webhook or a signed link valid for 24 hours.
Does rotating an image lose quality?
No. Rotation by 90-degree steps only reorders the existing pixels, so it's lossless — the only change is that width and height swap on a 90 or 270 turn.
What formats can I rotate?
The endpoint works with standard raster formats like JPG, PNG and WebP, and you can choose the output format.
Can I rotate many images in one workflow?
You send one image per request, but you can fire off many requests in parallel or script it into a batch job for large volumes.
For developers — API access
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.
API endpoint
One authenticated POST creates the task; the result comes back by webhook or a signed link. This capability is currently available through the API, not as an interactive Web tool.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/image/rotate \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"image":"https://ejemplo.com/imagen.jpg"}'const res = await fetch("https://api.kit.forhosting.com/image/rotate", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"image": "https://ejemplo.com/imagen.jpg"
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/image/rotate",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"image": "https://ejemplo.com/imagen.jpg"
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/image/rotate", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"image":"https://ejemplo.com/imagen.jpg"}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"image":"https://ejemplo.com/imagen.jpg"}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/image/rotate", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"image": "https://ejemplo.com/imagen.jpg"
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "image.rotate",
"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.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
max_mb | 15 |
max_megapixels | 12 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |