The modern alternative to ImageMagick is easy to use if you learn the basic commands.

  • Convert to one format to another
    gm convert image.png image.jpg
    

Resizing, cropping and compressing

  • Resize largest side (and keeping ratio) (-size 200x200 allows to make the process faster because it gives a hint to the JPEG decoder that the image is going to be downscaled to 200x200, `+profile “*” removes any ICM, EXIF, IPTC, or other profiles that might be present in the input)
    gm convert -size 200x200 image.jpg -resize 200x200 +profile "*" output.jpg
    
  • Resize shortest side (and keeping ratio)
    gm convert image.jpg -resize 120x120^ output.jpg
    
  • Change resolution only if image is larger
    gm convert image.jpg -resize '500x500>' output.jpg
    
  • Change resolution without keeping ratio
    gm convert image.jpg -resize 120x120! output.jpg
    
  • Change width (keeping ratio)
    gm convert image.jpg -resize '120x' output.jpg
    
  • Change height (and keeping ratio)
    gm convert image.jpg -resize 'x120' output.jpg
    
  • Resize and crop (create a thumbnail)
    gm convert image.jpg -resize 500x500^ -gravity center -crop 500x500+0+0 thumbnail.jpg
    
  • Change quality (compression)
    gm convert image.jpg -quality 50 output.jpg
    

Filters

  • Blur: -blur <radius>
  • Gaussian: -gaussian <radius>
  • Border: -bordercolor <color> -border <width>x<height>
  • Charcoal: -charcoal <factor>

Brightness, saturation, hue

  • Modulate: -modulate <brightness>,[<saturation>],[<hue>]
    gm convert image.jpg -modulate 100,0 grayscale.jpg
    
  • Gamma: -gamma <value>