Photo Rotator

Photo Rotator API

Design

Rotate a photo to any angle right in your browser. Crop back to the original size, or expand the canvas and fill the corners. Nothing is uploaded unless you use AI fill.

Authentication

All API requests require a valid API key passed in the Authorization header as a Bearer token.

Rate Limit

20 requests per minute

Endpoints

1 endpoint available

Overview

Rotate a photo to any angle and frame it, the same way the web page does. Send the image as multipart form data in the file field. The response body is a PNG.

Modes

  • crop (default): the output is the photo's size, or the largest box of aspect that fits it. The rotated photo is scaled up just enough to cover it, so there are no empty corners.
  • expand: the output grows to hold the whole rotated photo (widened to aspect if set), and the space around it gets fill: a hex colour or transparent.

Notes

  • Accepted input: JPEG, PNG, WebP, GIF, AVIF, TIFF and SVG, up to 20 MB and 50 megapixels. BMP, ICO and HEIC files return 415. Animated GIFs use the first frame.
  • angle is in whole degrees, clockwise. The EXIF orientation is applied first.
  • zoom is 1 to 4 in crop mode and 0.3 to 3 in expand mode; values outside the mode's range are clamped. panX and panY move the photo from the centre, in output pixels, and are clamped like the page's drag (crop mode never shows a gap).
  • The output can be at most 10000 pixels per side.
  • The page's AI fill is not available through the API.

Endpoints

POST
https://opentools.ca/api/v1/tools/photo-rotator
Rotate a photo to any angle and frame it

Request Body

Content-Type: multipart/form-data

ParameterTypeRequiredDescription
file
file
Required
The image, up to 20 MB and 50 megapixels. JPEG, PNG, WebP, GIF (first frame), AVIF, TIFF or SVG.
angle
number
OptionalRotation in whole degrees, clockwise, -360 to 360.Default: 0
mode
string
Enum: crop, expand
Optionalcrop fills the frame; expand pads around the rotated photo.Default: crop
aspect
string
Enum: original, 1:1, 4:3, 3:4, 16:9, 9:16
OptionalOutput ratio.Default: original
zoom
number
OptionalScale: 1 to 4 in crop mode, 0.3 to 3 in expand mode.Default: 1
panX
number
OptionalHorizontal offset of the photo in output pixels (positive moves it right).Default: 0
panY
number
OptionalVertical offset of the photo in output pixels (positive moves it down).Default: 0
fill
string
OptionalPadding for expand mode: a hex colour (#rrggbb) or "transparent".Default: #000000

Response Example

HTTP/1.1 200 OK
Content-Type: image/png
Content-Disposition: attachment; filename="photo-rotated.png"

<binary file data>

Error Codes

400
Bad Request - Missing file, invalid option, or output over 10000 pixels per side
401
Unauthorized - Invalid or missing API key
403
Forbidden - API key is inactive or expired, or the request IP is not allowed
413
Payload Too Large - File over 20 MB or image over 50 megapixels
415
Unsupported Media Type - Not an image the server can read (BMP, ICO and HEIC are not supported)
429
Too Many Requests - Rate limit exceeded
500
Internal Server Error

Code Examples

# Straighten a horizon by 3 degrees, cropping the corners
curl -X POST https://opentools.ca/api/v1/tools/photo-rotator \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "file=@beach.jpg" \
  -F "angle=-3" \
  -o beach-rotated.png

# Turn 45 degrees on a transparent square
curl -X POST https://opentools.ca/api/v1/tools/photo-rotator \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "file=@logo.png" \
  -F "angle=45" -F "mode=expand" -F "aspect=1:1" -F "fill=transparent" \
  -o logo-rotated.png

Ready to get started?

Create an API key to start using the Photo Rotator API.

Rather use it in your browser? Open the Photo Rotator