ImageMagick

ImageMagick is an extremely useful piece of software. There are several interfaces (graphical, commandline and library), but I prefer the commandline.

Correcting rotation

Yes, there's plenty of websites who will strip off the EXIF flags after uploading your JPEG and thus show your pictures in the wrong orientation. ImageMagick has a nice option for this. It'll read out the EXIF orientation flag, then rotate the image in the old-fashioned way:

 $ convert candelabra.jpg -auto-orient candelabra_rotated.jpg

Tiling

I often have a need to concatenate a number of images and create them as one image. Montage is wonderful for this:

 $ montage -geometry +0+0 -tile 1x2 image1.png image2.png montage.png

This will place the image1 above image2 (i.e. in a column). Thus 1x2 means, create a montage of 1 pictures wide and 2 pictures in height.

(So what I actually use it for, is to use VLC to save two scenes from a movie, then put it on Facebook...)

Padding while resizing

If you need to resize images to a certain size, you'll probably need to retain the width/height ratio. This is where the extent parameter comes in:

 $ convert -resize 250x50 -gravity center -extent 250x50 -background none \
    logo-home.png logo-home_small.png

In the above case, the background is set to none (i.e. transparent), but defaults to white.

Padding

To keep an image at the same size, but just pad it in a border of transparent pixels to get a touchable area of 50x50 pixels:

 $ convert small_button.png -gravity center -background none -extent 50x50 small_button_padded.png

Grayscale

The correct parameters to convert a color scan of some handwritten notes to black & white:

 $ convert notes.jpg -monochrome -colors 2 notes_bw.jpg

For background information: https://poizan.dk/blog/2014/02/28/monochrome-images-in-imagemagick/

EXIF

To strip EXIF data from an image:

 $ mogrify -strip image.jpg