10 Aug 2009

Convert all Images with imagemagick

Use imagemagick to convert down all images in one directory, ex. for web galleries

Simple Version

$ for i in *jpg; do convert -size 640 "$i" -resize 640 -quality 85 -strip "$i" ; done

One important thing is -strip which strips unneeded camera profiles and other stuff which can use as much as 60 KB.

Advanced Version

Version which i use for my article pictures on this website to create thumbnails

for i in *jpg; do convert "$i" -resize 480 "`basename "$i" .jpg`-480.jpg"; done

If you want to renanme alle files first with sequential numbers, use something like this before:

ls | cat -n | while read n f; do mv "$f" `printf "KungFu_%03d.jpg" $n`; done

Cheers