Bulk resize and rotate images according to EXIF data

First post of the blog and today’s issue.

I had to rotate, resize and upload over 20 images, the problem was that some images was getting some weird height and width values, that was due to some EXIF information about the orientation.

To solve that the bash command convert offer a pretty handy option: -auto-orient.

Therefore to bulk resize and rotate here a small snippet:

for i in *.jpg; do convert $i -auto-orient -resize 710 $(basename $i .jpg)_resized.jpg done

This will do the following:

  1. Read all the image names with the extension specified (*.jpg).
  2. Take each image, automatically rotate them according to the EXIF information then resize them to a width of 710px.
  3. After this, the image is stored with the original name followed by “_resized”.

There are of course many other way to do the same things, but that was the quicker I’ve found.


Your opinion is important!

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