Streaming image resizing API.
The API accepts images (jpeg, png and webp only) in binary format (not multipart form data) and returns the modified (or original) image.
npm install
npm run dev
// run the server in development
npm test
// run the test suite
The API supports the following requests:
- POST
/image/{file.ext}
- returns original image - POST
/image/[key_value,key_value]/{file.ext}
- ASCII URL encoding of[
,]
and,
. Returns the original images with the options applied. Options are a comma separated list with the formatkey_value
- POST
/image/m_{max}/{file.ext}
- returns the image resized with aspect ratio mantained so that the largest edge is less than or equal to the value ofmax
(number) in pixels - POST
/image/w_{width},h_{height}/{file.ext}
- ASCII URL encoding of,
. Returns the image with the width and height resized to fit withinwidth
(number) andheight
(number) while maintaining aspect ratio. A specifiedmax
value should be ignored if width and height are specified. - POST
/image/f_{format}/{file.ext}
- in addition to the returning the original or resized image, if a user specifies a format ofjpeg
,png
orwebp
the image should be returned in that format and not the original format
The request Content-Type
header must match the ext
section of the endpoint.
For example, "Content-Type: image/jpeg" header must be included in a request URL ending in "file.jpeg".
No validation is undertaken on the request "Accept" header.
A binary filesize limit of 2mb is applied to all requests.
If the request data exceeds this filesize limit a 413 is returned.
Content-Length header is set.