#!/bin/sh # src http://www.zmatt.net/files/jpegrotate for file in $* do echo $file rotate=`jhead $file |grep '^Orientation : rotate [0-9]\+$' | sed 's/^Orientation : /-/'`; jpegtran $rotate -optimize -copy all $file >$file.tmp && mv $file.tmp $file done