#!/bin/sh if [ $# -eq 0 ]; then echo "This script will overwrite Orientation EXIF tag from photo" echo "to top-left (normal) but ONLY if the photo is rotated." echo "Warning: This script will overwrite source files!" echo "" echo "Usage: $0 " exit 1 else I="$*" # existing file? if [ -f "${I}" ]; then EXIF=`exif -m --ifd=0 -t Orientation "${I}" 2> /dev/null` # is there EXIF tag? if [ $? -eq 0 ]; then # rotated? if [ "${EXIF}" != "Top-left" ] && [ "${EXIF}" != "Unknown value 0" ]; then echo "UNROTATING: $I ($EXIF)" #exif -t Orientation --remove -o "${I}" "${I}" > /dev/null exif --ifd=0 -t Orientation --set-value=1 -o "${I}" "${I}" > /dev/null fi else echo "EXIF Orientation TAG missing: ${I}" fi else echo "Missing file: ${I}" fi fi