Wednesday, 24 August 2005

ImageMagick

ImageMagick is the CLI graphics package for UNIX and can do amazing stuff in the right hands. I’ve been using it since, like… forever.

Resources:

Converting transparent PNG to JPEG and setting a background colour:

One of the stupidest tricks ever:

convert -scale 480 -quality 80 screenshot.png -bordercolor white -border 0x0 Image1.jpg

Batch Resizing and Cropping

Here’s a little Makefile for batch processing photos for the Vodafone 520 photoframe, which has an 800×480 LCD. If you have 6.3.8 or above, use 800×480^ as the resize specifier for best results on the center crop:

OPTS=-resize 800 -gravity Center -crop 800x480+0+0 -quality 100

SOURCES=$(wildcard Source/*.jpg)

JPEG=$(foreach file,$(SOURCES),$(subst Source/,Final/,$(file)))

all: jpeg

Final/%.jpg: Source/%.jpg
	convert $(OPTS) $^ $@

jpeg: $(JPEG)

clean:
	rm -f $(JPEG)