imapi
v1.0.1
Published
This is an image service with on the fly resize, filling, fitting capabilities. The service always keep aspect ratio of image, thus filling to a given size will scale + crop to avoid deformation.
Downloads
3
Readme
imAPI
This is an image service with on the fly resize, filling, fitting capabilities. The service always keep aspect ratio of image, thus filling to a given size will scale + crop to avoid deformation.
All returned images can be cached on the server if redis is available (recommended), and HTTP caching (Cache-Control header is filled properly) information is always sent for proper handling by the client (usually a browser).
Upload an image
$ curl -F "[email protected]" http://<imapiHost>/images
{
"id":"2b864a3c4e8e33b96d0dde5166f53cb4",
"width":200,
"height":150,
"format":"jpeg",
"space":"srgb",
"channels":3,
"hasAlpha":false,
"url":"http://<imapiHost>/images/2b864a3c4e8e33b96d0dde5166f53cb4"
}
Get an image
All modes will output the image in the same format as the originally uploaded image. If JPG was uploaded then JPG is given back to you. You can change this by querying a different format with ?format=png
or ?format=jpg
Supported queries
mode
:original
(default) |fill
|fit
width
: not specified = same as original |integer
height
: not specified = same as original |integer
format
: not specified = same as original |jpg
|png
background
: default torgba(0,0,0,255)
sharpen
:false
(default) ortrue
|on
background
is used when performing a fit
operation, to select the background color. It is alos used when asking for JPG format when the source was PNG with transparent background, to select the new background color. It hence flatten the image.
Original image
http://<imapiHost>/images/2b864a3c4e8e33b96d0dde5166f53cb4
Fill to a given width (keep aspect ratio)
http://<imapiHost>/images/2b864a3c4e8e33b96d0dde5166f53cb4?width=100&mode=fill
Fill to a given height (keep aspect ratio)
http://<imapiHost>/images/2b864a3c4e8e33b96d0dde5166f53cb4?height=50&mode=fill
Fill to a given size
http://<imapiHost>/images/2b864a3c4e8e33b96d0dde5166f53cb4?height=100&width=100&mode=fill
Fit to a given rectangle
http://<imapiHost>/images/2b864a3c4e8e33b96d0dde5166f53cb4?height=100&width=100&mode=fit&background=rgb(255,0,0)