Building notes, projects, and occasional rants

Image manipulation

Small CLI recipes for image transformation.

Center a image with padding

You want to change the dimensions of an image, filling the new spots with white space.

convert -size 512x512 xc:white in.png -gravity center -composite out.png

Resize with -extent plus -background will also work.

Resize image

convert in.png -resize 32x32 out.png

More at Resizing Images with ImageMagick.

Remove extra white space around image

convert in.png -trim out.png