ImageMagick

ImageMagick is a free and open-source software suite for displaying, converting, and editing raster image and vector image files.

Image Processing Options

Option Description
-flop Flop image in the horizontal direction
-flip Flip image in the vertical direction
-rotate 90 Rotate 90 degrees clockwise
-rotate -90 Rotate 90 degrees counter-clockwise (or -90 degrees)
-rotate 180 Rotate 180 degrees clockwise
-transpose Flip image in the vertical direction and rotate 90 degrees
-transverse Flop image in the horizontal direction and rotate 270 degrees
-trim Trim image edges
-resize 500x500 Resize image to 500x500 but keep the original aspect ratio
-resize 500*500\! Resize but ignore the aspect ratio (might come in handy sometimes)

For a full list of colors see https://www.imagemagick.org/script/color.php

# Create an image of size 1080x1920 with black background
convert -size 1080x1920 xc:black output.jpg

# Create an image of size 1920x1080 with blue background
convert -size 1920x1080 xc:blue output.jpg

# create an image of size 500x500 with turquoise background
convert -size 500x500 xc:turquoise2 zshell.jpg

Rotating Images

# Rotate an image +90 degrees (clock wise).
convert -rotate "+90" input.jpg output.jpg

# or since the "+" is optional one could simply do
convert -rotate "90" input.jpg output.jpg

# Rotate an image -90 degrees (counter clock wise).
convert -rotate "-90" input.jpg output.jpg

# Rotate an image 180 degrees (flip it upside down)
convert -rotate "180" input.jpg output.jpg

# Rotate all the images in the current directory 90 degrees
mogrify -rotate +90 *.jpg

# Rotate all the images in the current directory -90 degrees
mogrify -rotate -90 *.jpg

# Rotate all the images in the current directory 180 degrees
mogrify -rotate 180 *.jpg

Generating thumbnails

# create a jpg thumbnail or size 500x500 and preserve the aspect ratio
convert -define jpeg:size=500x500 input.jpg -auto-orient -thumbnail '500x500>' output.jpg

# generate thumbnails (in bulk) for all the .jpg files in a directory
mogrify -format jpg -define jpeg:size=500x500 -auto-orient -thumbnail '500x500>'  *.jpg