Advertisement
Guest User

Bad EXIF / rotated photos

a guest
Jan 9th, 2015
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.20 KB | None | 0 0
  1. #!/bin/sh
  2. #
  3. # This script will copy rotated photos to other directory
  4. # and remove Orientation EXIF tag from them.
  5. # It can be used for identify bad edited images - manually rotated w/o changing EXIF data.
  6. # This script doesn't write to source files.
  7. #
  8. # jc for http://piwigo.org/forum/viewtopic.php?id=19787
  9.  
  10. SRC='/home/user/fotos' # must exist
  11. DST='/home/user/fotos-rotated' # must exist
  12.  
  13. if [ $# -gt 0 ]; then
  14.   # exif binary
  15.   EXIF=`exif -m --ifd=0 -t Orientation "$*" 2> /dev/null`
  16.   # is there an exif?
  17.   if [ $? -eq 0 ]; then
  18.     if [ "${EXIF}" != "Top-left" ] && [ "${EXIF}" != "Unknown value 0" ]; then
  19.         echo "ROTATED: $* ($EXIF)"
  20.         cp -a "$*" "${DST}"
  21.         FILE=`basename "$*"`
  22.         exif -t Orientation --remove -o "${DST}/${FILE}" "${DST}/${FILE}" > /dev/null
  23.         # or test in rotated/ directory: find . -type f -iname "*.jpg" -exec exif -t Orientation --remove -o "{}" "{}" \;
  24. #    else
  25. #        echo "OK: $* ($EXIF)"
  26.     fi
  27.   fi
  28.  
  29.   # exiftool binary (pretty slow)
  30.   #EXIF=''
  31.   #EXIF=`exiftool -Orientation --struct "$*"|grep Rotate`
  32.   #if [ "${EXIF}" != "" ]; then
  33.   #  echo "ROTATED: $*"
  34.   #fi
  35. else
  36.   find ${SRC} -type f -iname "*.jpg" -exec $0 {} \;
  37. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement