Site icon The Ultimate Linux Newbie Guide

Quick Tip: convert images at the command line with ImageMagick

The ImageMagick Wizard

ImageMagick is a very mature tool. It’s been around for donkeys years and it even acts as the silent ‘back end’ to some of the best GUI-based image manipulation software. However, the jewel in ImageMagick’s crown is the tool called ‘convert’. As you can imagine, this tool converts images at the command line. It can do so in many ways, for example, it can resize, change image quality, change formats (eg PNG to JPEG) and much, much more.

This is a great example of the power of convert from http://climagic.org: Here you can see how to make thumbnails of images with filesnames in the range IMG_3000.JPG – IMG_3499.JPG:

for i in IMG_3[0-4]*.JPG ; do convert -quality 60 -geometry 300 $i thumbs/$i ; done

The example shows that through  simple one line command you can batch process many items with ease. Doing that with even the most substantial of image editing software is sometimes either impossible or a real challenge.

Here is one last example of its simplicity:

convert -resize 1024×768 original.JPG new.JPG

As you would expect, it simply changes the size of original.jpg down to 1024×768 pixels and outputs the new image in a new file called new.JPG.

Exit mobile version