rotate()
{
- ext=`echo "${1##*.}" |tr "[:upper:]" "[:lower:]"`
- [ "x$ext" = "x" ] && return 1 #no extension
+ ext=$(echo "${1##*.}" |tr "[:upper:]" "[:lower:]")
+ [ "$ext" = "" ] && return 1 #no extension
gq_metadata="$GQ_METADATA_DIR/$1.gq.xmp"
if [ -f "$gq_metadata" ] ; then
- gq_orientation=`exiv2 -PXkv "$gq_metadata"|grep Xmp.tiff.Orientation|sed -e "s|Xmp.tiff.Orientation *||"`
+ gq_orientation=$(exiv2 -PXkv "$gq_metadata"|grep Xmp.tiff.Orientation|sed -e "s|Xmp.tiff.Orientation *||")
+# shellcheck disable=2181
[ $? != 0 ] && exit 1
else
gq_orientation=
jpg|jpeg)
if [ -n "$gq_orientation" ] ; then
exiv2 -M "set Exif.Image.Orientation $gq_orientation" "$1"
+# shellcheck disable=2181
[ $? != 0 ] && exit 1
fi
if exiftran -aip "$1" ; then
# exiftran ignores xmp, set it manually
exiv2 -M "set Xmp.tiff.Orientation 1" "$1"
+# shellcheck disable=2181
[ $? != 0 ] && exit 1
#http://dev.exiv2.org/issues/639
if [ -n "$gq_orientation" ] ; then
exiv2 -M "set Xmp.tiff.Orientation 1" \
-M "set Exif.Image.Orientation 1" "$gq_metadata"
+# shellcheck disable=2181
[ $? != 0 ] && exit 1
fi
return 0
tif|tiff|png)
if [ -n "$gq_orientation" ] ; then
exiv2 -M "set Exif.Image.Orientation $gq_orientation" "$1"
+# shellcheck disable=2181
[ $? != 0 ] && exit 1
fi
if mogrify -auto-orient "$1" ; then
# mogrify ignores xmp, set it manually
exiv2 -M "set Xmp.tiff.Orientation 1" "$1"
+# shellcheck disable=2181
[ $? != 0 ] && exit 1
#http://dev.exiv2.org/issues/639
if [ -n "$gq_orientation" ] ; then
exiv2 -M "set Xmp.tiff.Orientation 1" \
-M "set Exif.Image.Orientation 1" "$gq_metadata"
+# shellcheck disable=2181
[ $? != 0 ] && exit 1
fi
return 0
rotate_image_file()
{
- ext=`echo "${3##*.}" |tr "[:upper:]" "[:lower:]"`
- [ "x$ext" = "x" ] && return 1 #no extension
+ ext=$(echo "${3##*.}" |tr "[:upper:]" "[:lower:]")
+ [ "$ext" = "" ] && return 1 #no extension
case "$ext" in
jpg|jpeg)
exiftran -i "$1" "$3"
+# shellcheck disable=2181
[ $? != 0 ] && return 6
return 0;
;;
tif|tiff|png)
mogrify "$2" "$3"
+# shellcheck disable=2181
[ $? != 0 ] && return 7
return 0;
;;
}
get_sidecars=
-if [ "x$1" = "x-g" ] ; then
+if [ "$1" = "-g" ] ; then
get_sidecars=yes
shift
fi
rotate_image_file=
rotation=
-if [ "x$1" = "x-r" ] ; then
+if [ "$1" = "-r" ] ; then
rotate_image_file=yes
shift
rotation="$1"
fi
preserve_mtime=
-if [ "x$1" = "x-t" ] ; then
+if [ "$1" = "-t" ] ; then
preserve_mtime=yes
shift
fi
if [ -n "$rotation" ] ; then
- if [ "x$rotation" = "x0" ] ; then
+ if [ "$rotation" = "0" ] ; then
exit 0
fi
- if [ "x$rotation" = "x2" ] ; then
+ if [ "$rotation" = "2" ] ; then
mogrify_param="-flop"
exiftran_param="-F"
fi
- if [ "x$rotation" = "x3" ] ; then
+ if [ "$rotation" = "3" ] ; then
mogrify_param="-rotate 180"
exiftran_param="-1"
fi
- if [ "x$rotation" = "x4" ] ; then
+ if [ "$rotation" = "4" ] ; then
mogrify_param="-flip"
exiftran_param="-f"
fi
- if [ "x$rotation" = "x5" ] ; then
+ if [ "$rotation" = "5" ] ; then
mogrify_param="-transpose"
exiftran_param="-t"
fi
- if [ "x$rotation" = "x6" ] ; then
+ if [ "$rotation" = "6" ] ; then
mogrify_param="-rotate 90"
exiftran_param="-9"
fi
- if [ "x$rotation" = "x7" ] ; then
+ if [ "$rotation" = "7" ] ; then
mogrify_param="-transverse"
exiftran_param="-T"
fi
- if [ "x$rotation" = "x8" ] ; then
+ if [ "$rotation" = "8" ] ; then
mogrify_param="-rotate -90"
exiftran_param="-2"
fi
done
# Bourne shell runs DO loops in a sub-shell
ret=$?
- [ $ret != 0 ] && exit $ret
+ [ "$ret" != 0 ] && exit "$ret"
else
[ ! -w "$file" ] && exit 5
if [ -n "$rotate_image_file" ] ; then
if [ -n "$preserve_mtime" ] ; then
- mtime=`mktemp "${TMPDIR:-/tmp}/geeqie-rotate.XXXXXXXXXX"` || exit 3
+ mtime=$(mktemp "${TMPDIR:-/tmp}/geeqie-rotate.XXXXXXXXXX") || exit 3
touch --reference="$file" "$mtime"
fi
touch --reference="$mtime" "$file"
rm "$mtime"
fi
- [ $ret != 0 ] && exit $ret
+ [ "$ret" != 0 ] && exit "$ret"
else
rotate "$file"
ret=$?
- [ $ret != 0 ] && exit $ret
+ [ "$ret" != 0 ] && exit "$ret"
fi
fi
done