make pa_exifautotran be more specific - only "skip" the known SOS error, and dont touch file if the output of the rotate is 0 bytes -- JUST IN CASE
This commit is contained in:
@@ -18,7 +18,7 @@ EOF
|
|||||||
exit 0;;
|
exit 0;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
case $(exiftool -t -s -s -s -n -IFD0:Orientation -IFD1:Orientation "$i") in
|
case $(jpegexiforient "$i") in
|
||||||
1) transform="";;
|
1) transform="";;
|
||||||
2) transform="-flip horizontal";;
|
2) transform="-flip horizontal";;
|
||||||
3) transform="-rotate 180";;
|
3) transform="-rotate 180";;
|
||||||
@@ -32,9 +32,20 @@ EOF
|
|||||||
|
|
||||||
if test -n "$transform"; then
|
if test -n "$transform"; then
|
||||||
echo Executing: jpegtran -copy all $transform "$i" >&2
|
echo Executing: jpegtran -copy all $transform "$i" >&2
|
||||||
jpegtran -copy all $transform "$i" > tempfile
|
jpegtran -copy all $transform "$i" > tempfile 2> err
|
||||||
rm "$i"
|
ret=$?
|
||||||
mv tempfile "$i"
|
err=`cat err`
|
||||||
jpegexiforient -1 "$i"
|
if [ "$ret" = "2" ] && [ "$err" != "Invalid SOS parameters for sequential JPEG" ]; then
|
||||||
|
echo "$0: FAILED to rotate jpeg with unknown failure - dont change file"
|
||||||
|
rm err
|
||||||
|
rm tempfile
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
# last sanity check - make sure tempfile is not empty
|
||||||
|
if [ -s tempfile ]; then
|
||||||
|
rm err
|
||||||
|
mv tempfile "$i"
|
||||||
|
jpegexiforient -1 "$i" > /dev/null
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user