Advertisement
Guest User

Photo unrotate

a guest
Feb 9th, 2015
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.86 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. if [ $# -eq 0 ]; then
  4.   echo "This script will rewrite Orientation EXIF tag from photo"
  5.   echo "to top-left (normal) but ONLY if the photo is rotated."
  6.   echo "Warning: This script will overwrite source files!"
  7.   echo ""
  8.   echo "Usage: $0 <one_photo_to_process>"
  9.   exit 1
  10. else
  11.   I="$*"
  12.   # existing file?
  13.   if [ -f "${I}" ]; then
  14.     EXIF=`exif -m --ifd=0 -t Orientation "${I}" 2> /dev/null`
  15.     # is there EXIF tag?
  16.     if [ $? -eq 0 ]; then
  17.       # rotated?
  18.       if [ "${EXIF}" != "Top-left" ] && [ "${EXIF}" != "Unknown value 0" ]; then
  19.         echo "UNROTATING: $I ($EXIF)"
  20.         #exif -t Orientation --remove -o "${I}" "${I}" > /dev/null
  21.         exif --ifd=0 -t Orientation --set-value=1 -o "${I}" "${I}" > /dev/null
  22.       fi
  23.     else
  24.       echo "EXIF Orientation TAG missing: ${I}"
  25.     fi
  26.   else
  27.     echo "Missing file: ${I}"
  28.   fi
  29. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement