Editing images

Chinks in my armour of learned Photoshop helplessness

October 16, 2018 — April 17, 2024

computers are awful
generative art
making things
photon choreography

1 graphicsmagic/imagemagick

graphicsmagick and imagemagick are similar, stand-offish rivals. Imagemagick is the “original”, whatever that might means in the tangled phylogeny of software intellectual property. Graphicsmagick has, AFAICT, a better API. They are usually interchangeable from a user perspective. From a developer perspective, IM pretends GM does not exist, whereas GM knows IM exists and thinks it is awful:

Here are some reasons to prefer GraphicsMagick over ImageMagick or other popular software:

  • GM is more efficient than ImageMagick so it gets the job done faster using fewer resources.
  • GM is much smaller and lighter than ImageMagick (3-5X smaller installation footprint).
  • GM is used to process billions of files at the world’s largest photo sites (e.g. Flickr and Etsy).
  • GM does not conflict with other installed software.
  • GM suffers from fewer security issues and exploits than ImageMagick.

1.1 imagemagick hacks

Fred Weinhaus’s imagemagick scripts show how to do a great many useful things, e.g. Histogram matching.

Beware the idiosyncratic licensing.

1.2 favicon

Old school:

convert favicon.png  -bordercolor white -border 0 \
      $ -clone 0 -resize 16x16 $ \
      $ -clone 0 -resize 32x32 $ \
      $ -clone 0 -resize 48x48 $ \
      $ -clone 0 -resize 64x64 $ \
      -delete 0 -alpha off -colors 256 favicon.ico


convert favicon.png -define icon:auto-resize=64,48,32,16 favicon.ico


G'MIC includes a world of image conversion including scriptable image processing pipelines. See, e.g., a hand-rolled fingerpainting filter via diffusion tenor fields. Also has GIMP and Krita plug-in versions.

G'MIC is a full-featured open-source framework for digital image processing It provides several user interfaces to convert / manipulate / filter / visualize generic image datasets, ranging from 1D scalar signals to 3D+t sequences of multi-spectral volumetric images, hence including 2D color images.

Doing animated GIFs? they are fiddly. Specialised tool gifsicle handles them.

3 vips


libvips is a demand-driven, horizontally threaded image processing library. Compared to similar libraries, libvips runs quickly and uses little memory. libvips is licensed under the LGPL 2.1+.

It has around 300 operations covering arithmetic, histograms, convolution, morphological operations, frequency filtering, colour, resampling, statistics and others. It supports a large range of numeric formats, from 8-bit int to 128-bit complex. Images can have any number of bands. It supports a good range of image formats, including JPEG, TIFF, PNG, WebP, FITS, Matlab, OpenEXR, PDF, SVG, HDR, PPM, CSV, GIF, Analyze, NIfTI, DeepZoom, and OpenSlide. It can also load images via ImageMagick or GraphicsMagick, letting it load formats like DICOM.

It comes with bindings for C, C++, and the command-line. Full bindings are available for Ruby, Python, PHP, .NET, Go, and Lua. libvips is used as an image processing engine by sharp (on node.js), bimg, sharp for Go, Ruby on Rails, carrierwave-vips, mediawiki, PhotoFlow and others. The official libvips GUI is nip2, a strange combination of a spreadsheet and an photo editor.

Moreover, it seems to optimally pipeline operations and stream them from disk, which is much better for typical use cases.