Checking usage

If you installed GraphicsMagick, do

$ gm
GraphicsMagick 1.3.12 2010-03-08 Q8 http://www.GraphicsMagick.org/
Copyright (C) 2002-2010 GraphicsMagick Group.
Additional copyrights and licenses apply to this software.
See http://www.GraphicsMagick.org/www/Copyright.html for details.

Usage: gm command [options ...]

Where commands include: 
    animate - animate a sequence of images
  benchmark - benchmark one of the other commands
    compare - compare two images
  composite - composite images together
    conjure - execute a Magick Scripting Language (MSL) XML script
    convert - convert an image or sequence of images
    display - display an image on a workstation running X
       help - obtain usage message for named command
   identify - describe an image or image sequence
     import - capture an application or X server screen
    mogrify - transform an image or sequence of images
    montage - create a composite image (in a grid) from separate images
       time - time one of the other commands
    version - obtain release version

Checking basic properties of image

$ identify Mathematica7.png 
Mathematica7.png PNG 1000x1048+0+0 DirectClass 8-bit 1.2M 0.000u 0:01

Geometry is given as <width>x<height>

Converting image format

Convert one image

$ convert source.png destination.jpg

Converting multiple images

$ mogrify -format jpg *.png

Resizing images

Resize to a certain width and height automatically chosen to maintain aspect ratio

$ convert source.jpg -resize 800 destination.jpg

Resize all JPEG files (assuming all have file names *.jpg) in the path

$ mogrify -resize 800 *.jpg

Resize to a certain width and height which has same aspect ratio as the original image

$ convert source.jpg -resize 800x600 destination.jpg

If the geometry specification <widht>x<height> has a aspect ratio different from that of the original. It resizes to a certain width or height, which ever has a larger resizing fraction, and determine the other edge size automatically such that aspect ratio is unchanged

$ convert source.jpg -resize 800x1000000 destination.jpg
$ convert source.jpg -resize 1000000x800 destination.jpg

Resize to a certain percentage

$ convert source.jpg -resize 75% destination.jpg

Compressing image

$ convert big_file.jpg -quality 60% small_file.jpg

Trim off the edges of an image

Removes any edges that are exactly the same color as the pixels at the corner of the image.

$ convert non_trimmed.jpg -trim trimmed.jpg

blog comments powered by Disqus