
Image Optimizer API
Web Development
Reduce image file sizes instantly to improve website speed and lower hosting costs. Compress JPEG, PNG, WebP, GIF and BMP images and save them as JPEG, PNG, WebP or AVIF.
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
Re-encode an image as JPEG, PNG, WebP or AVIF at a quality you choose, and optionally fit it inside a
width and height. Send the image as multipart form data in the file field. The response body is
the new image file.
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.
- The EXIF orientation is applied to the pixels, and all metadata (EXIF, GPS, ICC) is removed.
widthandheightare a box to fit inside, keeping the aspect ratio. Send one or both. The image can be enlarged to fit. The output can be at most 10000 pixels per side.- For PNG,
qualitybelow 100 makes sharp reduce the image to a smaller colour palette.
Endpoints
POST
https://opentools.ca/api/v1/tools/image-optimizerCompress an image and return the new file
Request Body
Content-Type: multipart/form-data
| Parameter | Type | Required | Description |
|---|---|---|---|
| file | file | Required | The image, up to 20 MB and 50 megapixels. JPEG, PNG, WebP, GIF (first frame), AVIF, TIFF or SVG. |
| format | string Enum: jpeg, png, webp, avif | Optional | Output format.Default: jpeg |
| quality | number | Optional | Quality from 1 to 100.Default: 80 |
| width | number | Optional | Maximum width in pixels, 1 to 10000. The aspect ratio is kept. |
| height | number | Optional | Maximum height in pixels, 1 to 10000. The aspect ratio is kept. |
Response Example
HTTP/1.1 200 OK
Content-Type: image/webp
Content-Disposition: attachment; filename="photo-optimized.webp"
<binary file data>Error Codes
400
Bad Request - Missing file, invalid option, or output over 10000 pixels per side401
Unauthorized - Invalid or missing API key403
Forbidden - API key is inactive or expired, or the request IP is not allowed413
Payload Too Large - File over 20 MB or image over 50 megapixels415
Unsupported Media Type - Not an image the server can read (BMP, ICO and HEIC are not supported)429
Too Many Requests - Rate limit exceeded500
Internal Server ErrorCode Examples
curl -X POST https://opentools.ca/api/v1/tools/image-optimizer \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@photo.jpg" \
-F "format=webp" \
-F "quality=75" \
-F "width=1600" \
-o photo-optimized.webpRather use it in your browser? Open the Image Optimizer