#!/bin/bash # # rotate-images: rotate each image given on the command line # # Gerald Oskoboiny, July 4 2003 # # source: http://impressive.net/software/photo/source/rotate-images # # @@ try jhead -autorot # # $Id: rotate-images,v 1.4 2008-07-15 20:33:01 gerald Exp $ # usage() { echo "usage:" echo echo " rotate-images file1 [file2 ... ]" echo echo " example: rotate-images foo1.jpg foo2.jpg foo3.jpg" echo exit } if [ $# -lt 1 ]; then usage; fi for f in $*; do orientation=$(epinfo -T Orientation "$f") if [ $orientation -eq 1 ]; then echo "$f" does not need rotating continue fi if [ $orientation -eq 6 ]; then degrees=90 fi if [ $orientation -eq 8 ]; then degrees=270 fi echo Rotating "$f"... mv "$f"{,.egp} jpegtran -rotate $degrees -copy all -outfile "$f" "$f.egp" && \ exiftool -q -overwrite_original -Orientation=1 -n $f && \ rm -f "$f".egp done # # changelog: # # $Log: rotate-images,v $ # Revision 1.4 2008-07-15 20:33:01 gerald # set exif orientation to 1 after rotation; don't keep trash around any more # # Revision 1.3 2007/01/30 09:06:28 gerald # switched to bash because no longer works as sh # # Revision 1.2 2005/12/12 00:59:03 gerald # added a note to try jhead -autorot # # Revision 1.1 2003/07/18 19:02:17 gerald # rotate each image given on the command line # # #