Friday, July 25, 2008

How to convert Multiple Images for emailing

Imagemagick is normally included with most linux distributions, but if it isn't then you can install it by typing the following
apt-get install imagemagick for debian based distributions
or yum install imagemagick for red hat derivative distributions.

imagemagick is an awesome and extremely powerful image manipulation tool. For more detailed and other uses of this great tool read the man pages ie. man convert or visit their website http://www.imagemagick.org.

I use imagemagic to quickly resize a large batch of jpg files so that they are a suitable size for emailing

cd into the directory that you have your images saved, the ones you want to resize

then type the following

for k in $(ls *.jpg); do convert $k -resize 800x600 re_$k; done

replace 800x600 with whatever size you want to resize your images to. eg 640x480 or 320x200 etc this command will go through your current directory and will convert all your .jpg files by creating new files, saving the new converted files to a new filename with re_ infront of the existing file name. The original files are left intact.

you can also convert your pictures to different formats ie
convert image.jpg image.bmp
or convert image.gif image.tiff
or convert image.png image.jpg
will convert between the different formats

you can also use it to convert to a pdf file or to convert a pdf file to a jpg
eg convert file.jpg file.pdf or convert file.pdf file.jpg

3 comments:

Anonymous said...

Thanks for this!

Anonymous said...

great! =)

Anonymous said...

Thank you very much, exactly what i was looking for!