|- convert -|- imdisplay -|- montage -|

I recently (2007.08.09) downloaded and installed ImageMagick, and this page is just some personal initial finding, as I try to discover how to use the powerful command line tools it offers.

Download and Install

From their site - -> Binary Releases -> Windows, I chose to install ImageMagick-6.3.5-5-Q16-windows-static.exe. I chose the 'static' because I do not have any need to utilize their DLL (shared library) Application Programming Interface (API) at this time.

They offered a Q8 and a Q16 version, and at this time not exactly understanding what this signifies, I chose the Q16 - at 16 bits-per-pixel ...

Running this EXE installed ImageMagick in C:/Program Files/ImageMagick-6.3.5-Q16, and I allowed it to modify the environment so this path was added into my PATH variable, so each of the EXE files installed can be run from the command line. The list of EXE programs was -


Then the trick was to discover what each would do ;=))



As perhaps expected, convert -help yields an enormous list of options. The most interesting is -resize geometry ... Here are some examples working on an image identified as follows :-

C:\...>identify DSCN0001.JPG
DSCN0001.JPG JPEG 1600x1200 1600x1200+0+0 DirectClass 8-bit 842.34kb 0.094u 0:01
C:\...>convert -resize 50x50 DSCN0001.JPG temp2.jpg
temp2.jpg JPEG 50x38 50x38+0+0 DirectClass 8-bit 8.66602kb
C:\...>convert -resize 100x100 DSCN0001.JPG temp2.jpg
temp2.jpg JPEG 100x75 100x75+0+0 DirectClass 8-bit 11.7832kb
C:\...>convert -resize 640x640 DSCN0001.JPG temp2.jpg
temp2.jpg JPEG 640x480 640x480+0+0 DirectClass 8-bit 130.768kb
C:\...>convert -resize 1200x1200 DSCN0001.JPG temp2.jpg
temp2.jpg JPEG 1200x900 1200x900+0+0 DirectClass 8-bit 397.375kb 0.063u 0:01
C:\...>convert -resize 1600x1600 DSCN0001.JPG temp2.jpg
temp2.jpg JPEG 1600x1200 1600x1200+0+0 DirectClass 8-bit 723.574kb 0.094u 0:01

This indicates that the aspect ratio of the original image is fully maintained. That is, even though a 'geometry' of say 100x100 was used, the resultant 'thumb' was 100x75. This implies a 'normal' resizing algorithm of something like the following is being used by the 'convert' application :-

   $thumb_size = 100;
   $ratio = $img_x / $img_y;
   if( $ratio > 1.0 ) {
      $new_img_x = $thumb_size;
      $new_img_y = round( $thumb_size / $ratio );
   } else {
      $new_img_x = round( $thumb_size * $ratio );
      $new_img_y = $thumb_size;

Also, the 'resize' value can be expressed as a percentage, like :-

C:\...>convert -resize 50% DSCN0001.JPG temp2.jpg
temp2.jpg JPEG 800x600 800x600+0+0 DirectClass 8-bit 193.381kb
C:\...>convert -resize 40% DSCN0001.JPG temp2.jpg
temp2.jpg JPEG 640x480 640x480+0+0 DirectClass 8-bit 130.768kb

One example not tried - suppose you want to convert 1.jpg, 2.jpg, 3.jpg, 4.jpg, and 5.jpg in your current directory to a GIF animation. Then this simple command does the trick :-

convert *.jpg images.gif

And conversely, you wanted to extract the first image from a GIF :-

convert images.gif[0] 1.jpg

Inline Image Resize - It is sometimes convenient to resize an image as they are read. Suppose you have hundreds of large JPEG images you want to convert to a sequence of PNG thumbnails :-

convert *.jpg -resize 120x120 thumbnail%03d.png

Here all the images are read in and subsequently resized, and written out. It is faster and less resource intensive to resize each image as they are read with the following, but I found this tended to 'crash' in the XP command prompt :-

convert *.jpg[120x120] thumbnail%03d.png

Of course, to process a complete folder, and output the 'thumbs' to another folder using the same file name, the powerful XP command prompt 'for' command can be used. The following, when placed in a batch file, would process all the *.jpg in one folder, '..\tempb\images', and output a 'thumb' of the same name to another folder, 'temp' :-

for %%I in (..\tempb\images\*.jpg) do convert -resize 150x150 "%%I" "temp\%%~nI.jpg"

Note the use of inverted commas around the file names, in case there is a space in the name, and the use of the %~nI modifier to extract just the file name from the command.

convert seems a very powerful, and easy to use command line application.


imdisplay (display)

This was easy! 'imdisplay' is a small GUI application that will read and display, they say over 100 formats. The 'display' seems only for unix/linux, in that it seeks the X-windows server! After the install they suggest running a small set of commands to verify the installation :-

  convert logo: logo.gif
  identify logo.gif
  imdisplay logo.gif

The convert utilizes a built-in 'logo' from the command 'logo:', and writes it to logo.gif. identify gives the details of the logo.gif as -

logo.gif GIF 640x480 640x480+0+0 PseudoClass 256c 8-bit 37.4414kb

And the imdisplay loads that GIF file into a GUI display application.


This is a cool application to join a bunch of say JPG files, into an index - a montage of images. The site gives an example like the following to collect a set of JPG files into a single sheet :-

montage  '*.jpg' -geometry 50x50+2+2  image_index.gif

The single inverted commas (') are only for unix/linux, to stop the command shell expanding it to a list of files instead of montage doing that. They must be left out, or double inverted commas (") used in the windows command shell.

This will generate an image index of all the JPG images in the local folder, and write it out to image_index.gif. The 50x50 controls the size of each, but it seems the aspect ratio is maintained. Not sure what the +2+2 does, although montage -help outputs :-

 -geometry geometry   preferred tile and border sizes

So perhaps this is the border sizes? And note the 'geometry' is only the 'preferred' tile size, since the aspect ratios of the original images is maintained.


checked by tidy  Valid HTML 4.01 Transitional