Monday, February 18, 2008

ImageMagick: the great tool for batch image procession

Do you know that you can edit images not only in graphical editors like Gimp (or Photoshop on Windows or Mac) but in command line also. You can say that it is difficult. Maybe. But not for all problems. And batch image procession is that problem.

ImageMagick
The official site: http://www.imagemagick.org/

Installing:
sudo apt-get install imagemagick

ImageMagick is the great tool for editing raster images. For example, you have about 100 images for processing. You must correct colors, correct gamma, increase sharpness, change resolution or format. And maybe you wanna add your logo to other image. Using tradional image editors in that case is very difficult. Because you can press many buttons again and again, it's very very difficult. But ImageMagick will help you.

Well, for example, we create a web-site about great singer Sarah Brightman and wanna upload a photo collection. I have ten images in 1024x768 resolution, I think they be good for it. Change the resolution of these images to 640x480 and add the logo in bottom right corner of each image. Logo is 100x50 image created by GIMP. After this we create black'n'white copy of each image.

There are our original images:



Now create the logo in GIMP and save it in logo.gif with alpha channel:



Create a script im.sh:

#!/bin/sh
for fname in *.jpg; do
mogrify -resize 640 $fname
composite -compose atop -gravity SouthEast logo.gif $fname $fname
convert $fname -colorspace GRAY bw-$fname
done


Make it executable:
chmod +x im.sh
and now we can launch it
./im.sh

Result will be like this:



As you can see each image have the logo in bottom right corner:



You also can use ImageMagick for batch image converting from one format to another. For example you have a folder with about two hundred images in .jpg format, but you wanna convert it to .png. You can use this command:
for fname in *.jpg; do convert $fname ${fname%.jpg}.png; done

That's all.

1 comment:

photo editing software said...

Hey Friends I think it's a good idea to using Batch photo editing software while we have a lot of Images for editing or conversion I also use ReaJPEG software with batch editing mode.