Welcome to WebmasterWorld Guest from 184.72.145.109

Forum Moderators: bakedjake

Message Too Old, No Replies

Resize and crop multiple images with ImageMagick

Resize and crop multiple images with ImageMagick

     
8:59 pm on May 12, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:Nov 8, 2005
posts: 83
votes: 0


I need to resize and crop all images in the specific directory using linux command line and ImageMagick.

I have a directory with 100K jpg images dimensions 264x198 pixels, which need to be resized to 176 pixels width and cropped to 176x110 from the top. The original images should be left as they are.

I can manualy resize and crop one image at a time with these two commands:


convert -resize 176 000000001.jpg w_000000001.jpg
convert -crop 176x110+0+0 w_000000001.jpg

How can I do this for all images (*.jpg) in the current directory?

Thanks a lot.

9:17 pm on May 12, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:Nov 8, 2005
posts: 83
votes: 0


Better question is:

How to make copies of all files in the specific directory?

Something like: cp *.jpg w_*.jpg ?

10:12 pm on May 12, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 27, 2001
posts:2547
votes: 0


You could do this with a perl script or a shell script. Shell might be:

for x in `ls *.jpg`; do `convert -resize 176 $x w_$x; convert -crop w_$x`; done

To simply make a copy is similar to the above...

7:21 pm on May 17, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:July 28, 2003
posts:188
votes: 0


Imagemagick already has a tool designed for batch processing of images, mogrify.

See [imagemagick.org...] for exact details.