Due to the wide range of screen sizes in web and mobile apps the images are often need to be resized on the fly for better user experience. But it can put unwanted load on the application server.
So, I end up developing a micro-service as a docker image. It provides an http end-point that takes the original image url, desired height, width & output image format as parameters and returns the resized image.
Source code: https://github.com/shahedk/image-resizer
docker pull shahedk/image-resizer:latest docker run -p 8080:80 shahedk/image-resizer:latest
The above script will start the container at http://localhost:8080. For example, the http request to resize an image from "http://cdn.shahed.ca/default.jpg" into 100x100 pixel of PNG image would look like this:
The service uses the sharp image libarary for resizing and supports PNG, JPEG, TIFF and WebP.