S3 Image resizer - an alternative way to handle thumbnails

It is a very common approach to store images on S3 - it is cheaper and helps you to forget about the pain of continuously adding space on your server. However, there is no solution out of the box to convert, crop, resize, and optimize images. If you try to search for a solution - you could probably find a "Lambda function" approach, mostly for AWS and some paid services.

Let me introduce an alternative way - a free, open-source solution to resize and optimize images on the fly from any S3 provider (not just AWS): https://github.com/kirill-zhirnov/s3-image-resizer

It is a web service, which resizes images by query params, e.g.:

http://localhost:3000/thumb/<local path on the S3>?mode=scale&max-size=500 - generates a scaled thumbnail with 500px size. The service is based on Node.js (Express/Typescript) and Imagick. All available query parameters could be found on the GitHub page.

On a request, the service fetches an image from S3 and generates a thumbnail with Imagick (executes CLI). The resulting image can be stored for caching purposes.

This approach:

  • Handle correctly images with Exif orientation (e.g. a photo saved in the landscape, but portrait should be used)
  • Can resize images of any size (even a big one, without memory limit issue)
  • Works fast
  • Can be easily extended
  • Works with any S3-based hostings

The service can be launched with Docker - it already has all the configs - just create a .env file and run.

The project was created as a part of boundless-commerce.com project. If you like the idea - please support us with a start on GitHub:


Kirill Zhirnov
Kirill Zhirnov