Image Processing Services
Infrastructure Estimated reading time: ~3 minutes
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
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 |
- https://github.com/willnorris/imageproxy/issues/175
- https://github.com/h2non/imaginary/issues/34
- https://github.com/imgproxy/imgproxy/blob/4bd745f76485934105cc1367b009fc1d3494283b/vips.go#L359
- https://github.com/imgproxy/imgproxy/issues/174. imgproxy initially made use of bimg (source).
Misc Notes
Thumbor
- Uses the Pillow engine (source). Can use other engines as well:
Pros
- Debian repo available.
- Starting multiple instances of thumbor can be achieved by specifying multiple ports in it’s config file.
Cons
- 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
- govips
- Go Image Filtering Toolkit
- imaging
Cloud services
- https://cloudinary.com
- https://imgix.com
- https://www.filestack.com
- 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
- 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
. Usinggo 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 buildinglibvips
from source though.
A note about Netcup (advertisement)
Netcup is a German hosting company. Netcup offers inexpensive, yet powerfull web hosting packages, KVM-based root servers or dedicated servers for example. Using a coupon code from my Netcup coupon code web app you can even save more money (6$ on your first purchase, 30% off any KVM-based root server, ...).