+ zenity --info --width=300 --height=100 --text="Export jpeg from raw file\n\njpgicc is not installed\ncolor corrections will not be made\nYou may install via liblcms2-utils" --title="Geeqie export jpeg" 2> /dev/null
+fi
+
+IFS='
+'
+
+exiv2_count=0
+if list=$(exiv2 --print preview "$1")
+then
+ if [ "$(echo "$list" | wc --words)" -gt 1 ]
+ then
+ exiv2_count=$(echo "$list" | wc --lines)
+ fi
+fi
+
+exiftool_count=0
+in_list=$(exiftool -veryshort -preview:all -orientation# "$1")
+if echo "$in_list" | grep --quiet Orientation -
+then
+ exiftool_count=$(($(echo "$in_list" | wc --lines) - 1))
+else
+ exiftool_count=$(echo "$in_list" | wc --words)
+fi
+
+if [ "$exiftool_count" -gt "$exiv2_count" ]
+then
+ use_exiftool="true"
+ count="$exiftool_count"
+else
+ count="$exiv2_count"
+fi
+
+if [ "$use_exiftool" = "true" ]
+then
+ # An integer value is returned by a # suffix
+ in_list=$(exiftool -veryshort -preview:all -orientation# "$1")
+
+ if [ "$(echo "$in_list" | wc --lines)" -gt 0 ]
+ then
+ # $in_list is in the form of lines e.g.
+ #
+ # OtherImage: (Binary data 138367 bytes, use -b option to extract)
+ # PreviewImage: (Binary data 138367 bytes, use -b option to extract)
+ # ...
+ # Orientation: 8
+
+ if echo "$in_list" | grep --quiet Orientation -
+ then
+ orientation=$(echo "$in_list" | tail --lines=1 | cut --delimiter=' ' --fields=2)
+ count=$(($(echo "$in_list" | wc --lines) - 1))
+ list=$(echo "$in_list" | head --lines=-1 | sort --field-separator=: --key=2 --sort=human-numeric --reverse)
+ else
+ orientation=0
+ list="$in_list"
+ fi
+ else
+ count=0
+ fi
+else
+ orientation_str=$(exiv2 -g Exif.Image.Orientation -pv "$1")
+
+ # orientation in the form e.g.
+ # 0x0112 Image Orientation Short 1 8
+
+ orientation=$(echo "$orientation_str" | tr --squeeze-repeats ' ' | cut --delimiter=' ' --fields=6)