Image manipulation using Image Magick

July 16, 2006
In an earlier post, I had reviewed Gimp - a robust image manipulation software which is installed by default in most Linux distributions. Gimp can no doubt be held at par with the industry leader Adobe Photoshop at least in creating images for the web. But sometimes a situation arises where it is not feasible to use a GUI based software to modify images; perhaps because the machine does not have a running X server or you need a tool which allows you to do batch conversions of 100s of images to the required size.

Fortunately, there is a very powerful suite in Imagemagick. I call it a suite because it is actually a collection of tools (11 to be exact), each of which accomplishes a particular task. These tools are as follows:
  • animate - This tool can be used to create animated Gifs.
  • compare - This is used to mathematically and visually show the difference between two images.
  • composite - Used to overlap one image over another.
  • conjure - This tool is used to execute scripts written with the special scripting language called Magick Scripting Language.
  • convert - This is a versatile tool in that apart from using to convert between a variety of image formats, it can also used to do many image manipulations like crop,blur, join two images and so on.
  • display - Shows an image on any X server.
  • identify - displays the properties of an image including its size, dimentions and type of image.
  • import - This is an interesting tool to capture screenshots of the desktop or even the console if one is working in the console. The output can be saved even in postscript format.
  • mogrify - The use of this tool is similar to the convert tool but with one difference in that mogrify will overwrite the current image where as convert will write the result into a different image.
  • montage - create a composite image such as providing a border to the image, placing text and so on.
  • stream - a lightweight tool to stream one or more pixel components of the image or portion of the image to your choice of storage formats.
I usually use Gimp for all my image editing needs and so am not so fluent in using Image Magick suite. Carson McDonald has put together a very interesting tutorial in using two of the tools (convert and montage) in the Image Magick suite to illustrate some of the special effects.

4 comments:

  • virens

    Great article! A used ImageMagick in PERL script to convert dozens of TIFFs to one PDF with image processing. It`s very robust, but it`s very slow with bluring and sharpening (i think that they dont use FFT and do image processing with convolution, that is 6 times slower).
    I would publish on my blog scientific programs review, and i will post a link here. Great article!

  • kamesh

    Thanks a lot for that information Ravi. It was very useful.

  • havoc

    for i in `find path/to/files -name "*jpg"`; do convert -quality 85 -geometry 600x600 -unsharp 0 path/to/files/$i tmp/path/$i; done

    viola! web-res images from your photos.

  • Gayathri

    Great article about image magick. From this article i understood that, image manipulation can be done by using image magick. I use GIMP for doing image manipulation. Let me try with image magick. Keep blogging. Thanks.