BloodwebMicroservices Sign in
← All microservices

Image resizer

Images

Resize an image to fit inside a box, fill it and crop, fit and pad, or stretch to exact dimensions.

What it does

  • Four ways to fit: inside, cover, pad and exact
  • Choose which part to keep when cropping
  • Never enlarges small images unless you ask
  • Returns the final size with the image

Good for

  • Product photos
  • Thumbnails and avatars
  • Social media images

Ask for a box and pick how the image fills it. Cover suits thumbnails and grids; pad suits product photos that must not be cropped.

Example

POST https://bloodweb.net/api/v1/image-resize

curl -H "Authorization: Bearer YOUR_KEY" -F file=@photo.jpg -F width=800 -F height=800 -F fit=cover https://bloodweb.net/api/v1/image-resize -o thumb.jpg

Options

NameDescription
file
file
The image, up to 25MB: jpg, png, gif, webp, bmp, tiff, heic, avif, ico.
width Target width in pixels. Give width, height or both.
height Target height in pixels.
fit inside: fit within the box, keeping proportions. cover: fill the box and crop the overflow from the centre. pad: fit within the box and fill the rest with the background. exact: stretch to the box. cover, pad and exact need both width and height.
One of: inside, cover, pad, exact
Default: inside
gravity Which part of the image to keep when fit=cover crops it.
One of: center, top, bottom, left, right, top-left, top-right, bottom-left, bottom-right
Default: center
upscale Allow enlarging an image smaller than the box (inside and pad).
Default: false
to Output format. Defaults to the input format (HEIC becomes JPG, ICO becomes PNG).
One of: jpg, png, webp, avif, gif, tiff, bmp
quality For JPG, WebP and AVIF.
Default: 85
background Padding colour for fit=pad, or "transparent" where the format allows it.
Default: #ffffff
strip Remove metadata.
Default: true

Returns

The resized image. X-Image-Width and X-Image-Height give its final size.