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

  1. your software is performant enough,
  2. your hardware is strong enough and
  3. 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

Project Language Licence Face detection Libs Status
imgproxy Go MIT (some features only available in Pro version) Smart Crop (see 3) libvips (direct, see 4)
thumbor Python MIT Yes Pillow engine
imaginary Go MIT Smart Crop (see 2) libvips and bimg
pilbox Python Apache-2.0 Yes Pillow engine Unmaintained
picfit Go MIT No Only Go
imageproxy Go Apache-2.0 Smart Crop (see 1) Only Go
sharp JS Apache-2.0 libvips
imageserver Go MIT GIFT, nfnt resize, Graphicsmagick
  1. https://github.com/willnorris/imageproxy/issues/175
  2. https://github.com/h2non/imaginary/issues/34
  3. https://github.com/imgproxy/imgproxy/blob/4bd745f76485934105cc1367b009fc1d3494283b/vips.go#L359
  4. https://github.com/imgproxy/imgproxy/issues/174. imgproxy initially made use of bimg (source).

Misc Notes

Thumbor

Pros

  • Debian repo available.
  • Starting multiple instances of thumbor can be achieved by specifying multiple ports in it’s config file.

Cons

Image processing libraries (mainly Go)

Cloud services

Client side solutions

  • smartcrop.js
    • The project offers a nice online testbed. There you can try to crop an image using various JavaScript face detection libraries (face-api.js, …).

imaginary on Debian 9

  • Install libvips-dev.
  • Build the package using go build. Using go get does 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-dev to install any transitive depdencies of required when building libvips from 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, ...).