Image processing with ImageMagic

Batch resize all JPEG images in the directory and save them with a different name:

for i in `ls *.jp*g`; do convert -resize 50% -quality 80 $i conv_$i; done

Resize all JPEG images in the current directory to 1440 pixels height, strip EXIF info and save into subdirectory “resized”* with prefix “s_” added to the file name.

for i in `ls *.jp*g`; do convert -geometry x1440 -quality 85 -strip $i ./resized/s_$i; done

Resize all JPEG images in the current directory to 1440 pixels at the shortest edge (that is, in accordance to the orientation), strip EXIF info and save into subdirectory “resized”* with prefix “s_” added to the file name.

for i in `ls *.jp*g`; do convert -resize 1440x1440^ -quality 85 -strip $i ./resized/s_$i; done

Add “-auto-orient” to the parameter string, if you want to use EXIF orientation tag to rotate the image.

* NOTE: Directory must exist.

And, finally, a snippet that creates a subdirectory, case insensitively lists all JPEG image files and processes them:

subdirname=resized; mkdir -p $subdirname; for i in `ls *.[jJ][pP]*[gG]`; do convert -resize 1440x1440^ -quality 85 -strip -auto-orient $i ./$subdirname/s_$i; done

 

Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s