Welcome to WebmasterWorld Guest from

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)

5+ Year Member

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)

5+ Year Member

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)

WebmasterWorld Senior Member 10+ Year Member

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)

10+ Year Member

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

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


Featured Threads

Hot Threads This Week

Hot Threads This Month