What is this?
This service allows you to dynamically manipulate images on the flying using a HTTP API. What this really means is that you don't have to bother building in image resizing logic into your application, just access the image through this API.
If your application allows a user to upload an image to http://myapp.com/user/profile.png at 2000px by 2000px, then you can access a 100px by 100px version of that image by visiting https://api.imgrszr.com/?image=http://myapp.com/user/profile.png&width=100.
How do I use it?
Construct a URL consisting of the following parameters:
- image - (required) The publicly accessible URL of the image that you want to resize.
- width - (optional, must provide at least one dimension) The desired width of the resulting image in pixels.
- height - (optional, must provide at least one dimension) The desired height of the resulting image in pixels.
- purge - (optional) Set to a value of 1 to reprocess an image. This is useful if the source image has changed and you urgently need a reprocess. Using this for the serving of images is considered an antipattern.
If one of width or height is omitted then the missing value is calculated respecting the aspect ratio of the source image.
Here are some examples using the API. View the source to see the URLs and how they have been constructed.
Resizing to width
Resizing to height
Resizing to box
Responsive imagery (using srcset)
How does it work?
The service works by downloading your source image, performing your requested manipulation, uploading the resultant image to a CDN, then performing a 301 redirect to the CDN URL.