Rotate image by degrees
Rotate Image by Degrees calculates the pixel dimensions needed to contain a rectangular image after rotation.
Run — free
Enter the original width, height, and clockwise angle. Multiples of 90 degrees are accepted by default and return exact unchanged or swapped dimensions. Enable free rotation for any finite angle, and the calculator returns the smallest axis-aligned whole-pixel box that contains the rotated rectangle. It performs geometry only: no image is uploaded, decoded, stored, or modified, making the result suitable for layout planning and automated image pipelines.
Calculate the box for quarter-turn rotation
Provide the source width and height as positive whole pixels, then enter a rotation angle. By default, the angle must be a multiple of 90 degrees. A rotation of 0 or 180 degrees keeps the bounding dimensions in the same order, while 90 or 270 degrees swaps width and height. The same rule applies to negative angles and angles beyond one full turn because the calculator normalizes the angle into an equivalent position from 0 up to, but not including, 360 degrees. For example, rotating a 1920 by 1080 image through 90 degrees produces a 1080 by 1920 box, and rotating it through 450 degrees produces the same result. Quarter turns are handled with exact integer logic rather than trigonometry, avoiding tiny floating-point errors around right angles. The returned values describe the output canvas required to contain the rotated rectangle. They do not represent a resized image, and the capability does not rotate, upload, inspect, or alter image pixels.
Enable free rotation for arbitrary angles
Set free_rotate to true when the angle is not a multiple of 90 degrees. The calculator treats the source as a rectangle centered at the rotation origin and computes the smallest axis-aligned bounding box around its rotated corners. Its width is based on the absolute horizontal contributions of the original width and height; its height uses the corresponding vertical contributions. Because a real-valued geometric result can land between pixels, each side is rounded outward to the next whole pixel. Rounding outward is intentional: rounding to the nearest pixel could make the canvas too small and clip an outer edge or corner. A square generally needs a larger box near 45 degrees, while a long landscape image may expand substantially in height even for a modest tilt. The direction is clockwise by convention, but positive and negative versions of the same absolute tilt produce equal bounding dimensions because the containing box depends on the magnitudes of sine and cosine, not on which corner moves upward.
Use the result safely in image workflows
Use the returned width and height to create a destination canvas, reserve space in a layout, estimate memory, or configure a downstream image-processing command. The calculation assumes rotation around the rectangle's center and an axis-aligned output canvas. If another tool rotates around a corner, applies perspective, trims transparent pixels, adds a border, or expands with custom padding, its final dimensions can differ. Source dimensions must be positive integers no larger than one billion pixels, and the angle must be a finite number. The free_rotate field must be a real boolean rather than a text value such as "true". Invalid values are rejected instead of being silently coerced, which keeps automated workflows predictable. The algorithm has no network calls, random values, current-time dependency, file decoding, or hidden state, so identical input always returns identical output. API automation costs $0.002 per request, while the browser implementation can run the same pure calculation without sending an image anywhere.
What you can do with it
Prepare a rotation canvas
Allocate an output canvas large enough to contain every corner of a rotated image without clipping.
Plan responsive layouts
Reserve accurate width and height before a rotated graphic is rendered in a page or application.
Build image-processing commands
Calculate destination dimensions before passing rotation settings to a separate graphics library or service.
FAQ
Does this capability rotate the image itself?
No. It calculates bounding-box dimensions only and never receives or modifies image pixels.
Why are non-right angles rejected by default?
The default protects workflows that expect exact quarter-turn dimensions. Set free_rotate to true to allow any finite angle.
How are fractional bounding dimensions handled?
Each side is rounded upward to a whole pixel so the destination canvas does not clip the rotated rectangle.
Can I use negative angles or angles over 360 degrees?
Yes. Angles are normalized to their equivalent position within one complete turn.
What does an API request cost?
Each API request costs $0.002.
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
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.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/image/rotate-degrees \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"width":1920,"height":1080,"angle":90}'const res = await fetch("https://api.kit.forhosting.com/image/rotate-degrees", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"width": 1920,
"height": 1080,
"angle": 90
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/image/rotate-degrees",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"width": 1920,
"height": 1080,
"angle": 90
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/image/rotate-degrees", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"width":1920,"height":1080,"angle":90}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"width":1920,"height":1080,"angle":90}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/image/rotate-degrees", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"width": 1920,
"height": 1080,
"angle": 90
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "image.rotate_degrees",
"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. |