This page describes ImageMagic commands which can be used to improve outputs from your GIS program. The ImageMagic software package is a free and open source software containing several tool for image manipulation. They can be used on all major platforms (Mac OS X, Linux, MS Windows) through GUI, or in my case command line (you just copy and past command from here to the command line).
Changing format
One of the most useful commands is here to convert TIFF from GRASS GIS 3D viewer (NVIZ) to PNG:
convert grass_3d.tif grass_3d.png
Generally speaking, GRASS 3D visualization tool (NVIZ) saves images in PPM or in TIFF format. We can convert these formats to PNG or JPEG using tools provided by the ImageMagic software package.
Following command converts TIFF (.tif) images to PNG images (creates new images in the current directory):
mogrify -format png *.tif
Trimming (cropping)
The other usage of the ImageMagic tools is when saving images from GRASS map display which can save some white space at the image borders (because the map does not fill the whole displayed area).
Following command crops parts of the image which contains only background (aka zealous crop):
mogrify -trim *.png
Images as edited in place, so the old images are lost (if you want to save them, copy them to different directory first).
Creating a GIF animation
Following command converts animated GIF (.gif) image(s) to the series of PNG images (creates new images in the current directory):
mogrify -format png *.gif
Getting info about the image
The following command provides basic info about an image:
identify my_image.png
Changing the size
Resize all images with .png extension which are bigger than given size to that size:
mogrify -resize '600x600>' '*.png'
It modifies images in place. The single quotes should work for most operating systems. Linux users may leave out the quotes for files.
Changes the size of the image and does not keeps ratio:
convert my_image.png -liquid-rescale 785x648\! my_image_resized.png
It tries to stretch the image nicely. Although, we should not use this command to provide the most accurate results, it can be sometimes used to match size of two images when we was not able to obtain these two images in exactly same size.
Other alternative tools
For some tasks such as manual cropping I use Shutter (available only on Linux) which is focused on screenshots, so cropping is there really great. For more complicated tasks Gimp is the right choice. To create images which involves vectors, I use Inkscape. For quick image re-sizing or rotations (by right click in file manager) I use image manipulation extension for Nautilus (available only on Linux).