Image Resize
Resize an image by exact dimensions with optional aspect ratio preservation
/v1/image/resize
curl "https://image.toolkitapi.io/v1/image/resize?url=https://toolkitapi.io/static/samples/sample-image.png&width=800&height=600&maintain_aspect=true&format=jpeg&quality=85"
import httpx
resp = httpx.get(
"https://image.toolkitapi.io/v1/image/resize?url=https://toolkitapi.io/static/samples/sample-image.png&width=800&height=600&maintain_aspect=true&format=jpeg&quality=85",
)
print(resp.json())
const resp = await fetch("https://image.toolkitapi.io/v1/image/resize?url=https://toolkitapi.io/static/samples/sample-image.png&width=800&height=600&maintain_aspect=true&format=jpeg&quality=85", {
});
const data = await resp.json();
console.log(data);
# See curl example
{
"image": "/9j/4AAQSkZJRgABAQ...(base64 data)...",
"format": "jpeg",
"original_size": {"width": 4032, "height": 3024},
"new_size": {"width": 800, "height": 600}
}
Try It Live
Description
How to Use
1. Provide the source image via the `url` query parameter.
2. Set `width` and/or `height` in pixels. Provide both for exact sizing, or just one for proportional scaling.
3. Set `maintain_aspect` to true (default) to prevent distortion when both dimensions are specified.
4. Choose the output `format` and `quality` for the resized image.
About This Tool
Use the Image Resize endpoint to change an image's dimensions by specifying target width and/or height. When `maintain_aspect` is true and both dimensions are given, the image is fitted within the bounding box without distortion.
If only width or height is provided, the other dimension is calculated automatically to preserve the aspect ratio. The endpoint uses Lanczos resampling for high-quality downscaling and upscaling.
Why Use This Tool
- Thumbnail generation — Create consistent-sized thumbnails for galleries and listings
- Responsive images — Generate multiple sizes for srcset responsive image delivery
- Upload standardisation — Normalise user-uploaded images to maximum dimensions
- Social media — Resize images to platform-specific dimensions (1080x1080, 1200x630, etc.)
- Email optimisation — Shrink images for faster email loading
Frequently Asked Questions
What resampling algorithm is used?
What happens if I provide both dimensions with maintain_aspect=true?
Can I upscale images?
Start using Image Resize now
Get your free API key and make your first request in under a minute.