← All microservices
Image compressor
Images
Shrink an image for the web: lower quality, strip metadata, cap the width, or switch to WebP or AVIF.
What it does
- Hit a target size, such as under 200KB
- Switch to WebP or AVIF for bigger savings
- 256-colour mode for screenshots and graphics
- Gives back the original if it cannot be made smaller
Good for
- Upload limits on forms and marketplaces
- Faster page loads
- Email attachments
A target size is the easy way to meet an upload limit: ask for 200KB and you get the best quality that fits.
Example
POST https://bloodweb.net/api/v1/image-compress
curl -H "Authorization: Bearer YOUR_KEY" -F file=@hero.png -F to=webp -F quality=75 https://bloodweb.net/api/v1/image-compress -o hero.webp
Options
| Name | Description |
|---|---|
filefile |
The image, up to 25MB: jpg, png, gif, webp, bmp, tiff, heic, avif, ico. |
quality
|
Lower is smaller. 70 to 80 is a good range for photos. Default: 75 |
max_width
|
Shrink wider images to this width. Never enlarges. |
to
|
Output format. Defaults to the input format (HEIC becomes JPG). One of: jpg, png, webp, avif, gif, tiff, bmp |
target_kb
|
Aim for a file no bigger than this many kilobytes. The highest quality that fits is used (JPG, WebP and AVIF). If even the lowest quality is too big, set max_width as well. |
lossy_png
|
Reduce PNGs to 256 colours. Much smaller for graphics and screenshots; not for photos. Default: false |
Returns
The smaller image. X-Original-Bytes and X-Output-Bytes give both sizes; X-Quality the quality used, and X-Target-Met whether target_kb was reached. When compression would not help, the original comes back unchanged with X-Kept-Original: true.