Suppose you run a website with a huge amount of user generated content (especially images). Ideally you would store the original images uploaded by your users. Nowadays pictures taken with modern smartphones often take up to 10 MiB. Delivering such big images in e.g. a list view is not an option. You will have to generate thumbnails for your images. This blog post gives an you an overview about some of the solutions you can use (server software, cloud solutions and also client software).
Your first option is to generate various versions of an image right after it is uploaded by the user. The downside to this approach is that each time you want to request e.g. another resolution you would have to run the generation process again. Furthermore this approach takes up a lot of storage space. Most of the time a better approach is to generate the thumbnails on the fly. Your users won’t even notice as long as
- your software is performant enough,
- your hardware is strong enough and
- you make use of content caching.
Furthermore an image processing service should be able to crop images around parts which are most interesting for humans (faces, …).
Server side solutions
|imgproxy||Go||MIT (some features only available in Pro version)||Smart Crop (see 3)||libvips (direct, see 4)|
|imaginary||Go||MIT||Smart Crop (see 2)||libvips and bimg|
|imageproxy||Go||Apache-2.0||Smart Crop (see 1)||Only Go|
|imageserver||Go||MIT||GIFT, nfnt resize, Graphicsmagick|
- https://github.com/imgproxy/imgproxy/issues/174. imgproxy initially made use of bimg (source).
- Uses the Pillow engine (source). Can use other engines as well:
- Debian repo available.
- Starting multiple instances of thumbor can be achieved by specifying multiple ports in it’s config file.
- Thumbor utilizes only one CPU core
Image processing libraries (mainly Go)
- pigo, Go: Pure Go face detection, pupil/eyes localization and facial landmark points detection library
- libvips, C++
- bimg (Go bindings). Maintained by the maintainer of imaginary.
- smartcrop, Go
- Go Image Filtering Toolkit
- Amazon Serverless Image Handler
- Makes use of Sharp and AWS Cloud.
- Can crop images using the facial recognition capabilities of Amazon Rekognition.
Client side solutions
imaginary on Debian 9
- Install libvips-dev.
- Build the package using
go build. Using
go getdoes not work currently.
- Binaries compiled with Go 1.11 will panic when invoking smartcrop. When using Go 1.14 it works.
- When compiling with Go 1.14 you need to use a recent libvips version (v8.9.2 works). Otherwise the linking step during go build will fail. You have to install
libvips-devto install any transitive depdencies of required when building
libvipsfrom source though.
A note about Netcup
Netcup offers inexpensive, yet powerfull web hosting packages, KVM-based root servers or dedicated servers for example. Using a code generated by my Netcup coupon code generator you can even save more money (5$ on your first purchase, 30% off any KVM-based root server, ...).