Auto rotate photos and save them afterwards (perhaps using Preview?)

photospreview

So I was previewing some photos using Preview app and I notice that Preview (at least on 10.10.5 Yosemite) automatically fixes rotation issues on the thumbnail on the left.

e.g. photo is upside-down when viewing it but the thumbnail shows it the right-side up. On preview, I still have to go through each photo and manually rotate them to make the changes permanent.

Do you know of any freebie app (or not so expensive) or perhaps using Preview? I want the app to ignore pics that's right-side up.

Best Answer

I came across a binary called "nconvert". I copied these to /usr/local/bin. I then created a simple recursive shell script to go through the folder and subfolders and convert any photo that needs converting.

#!/bin/sh

function recursion {
    if [ $(find . \( -iname "*jpeg" -or -iname "*jpg" \) -maxdepth 1 -type f | wc -l) -gt 0 ]; then
        _fullpath=`pwd`
        echo "Processing $_fullpath"
        echo "Processing $_fullpath" > $HOME/logs/recursive-autorotate-photos.log
        nconvert -jpegtrans exif -overwrite *.jpg
    fi

    for _item in *; do
        if [ -d "$_item" ]; then
            (cd "$_item"; recursion)
        fi
    done
}

if [ ! -z "$1" ]; then
    if [ ! -d "$HOME/logs" ]; then
        mkdir "$HOME"/logs
    fi
    echo "" > $HOME/logs/recursive-autorotate-photos.log

    cd "$1"

    recursion
else
    echo "Usage: recursive-autorotate-photos.sh path-here"
fi

sample: # recursive-autorotate-photos.sh "/Volumes/my-external-disk/photos"

take note of the quotes in the path. if there's a space in the path, there you need to enclosed it in double quotes. I always use double quotes now out of habit.