Difference between revisions of "ImageMagick"
From Noah.org
Jump to navigationJump to searchLine 11: | Line 11: | ||
</pre> | </pre> | ||
Which is true unless you want to convert a group of images. In that case, you use Mogrify instead of Convert. Why? I would call this a bug. If you try this with Convert it will not work (and will, in fact, destroy the last image in your directory). | Which is true unless you want to convert a group of images. In that case, you use Mogrify instead of Convert. Why? I would call this a bug. If you try this with Convert it will not work (and will, in fact, destroy the last image in your directory). | ||
+ | |||
+ | It sure beats doing it this way: | ||
+ | <pre> | ||
+ | for i in *.png | ||
+ | do | ||
+ | echo $i | ||
+ | convert -quality 85 $i `basename $i .png`.jpg | ||
+ | done | ||
+ | </pre> |
Revision as of 18:14, 18 June 2007
Convert all images in a directory from one format to another
This is easy. Use Mogrify, not Convert. The following example converts all PNG files to JPEG:
mogrify -format jpg -quality 85 *.png
I always forget this. Maybe it's because the ImageMagick docs say:
Mogrify overwrites the original image file, whereas, convert writes to a different image file.
Which is true unless you want to convert a group of images. In that case, you use Mogrify instead of Convert. Why? I would call this a bug. If you try this with Convert it will not work (and will, in fact, destroy the last image in your directory).
It sure beats doing it this way:
for i in *.png do echo $i convert -quality 85 $i `basename $i .png`.jpg done