summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorWojciech Siewierski <wojciech.siewierski@onet.pl>2017-12-06 12:36:05 +0100
committerWojciech Siewierski <wojciech.siewierski@onet.pl>2017-12-06 13:24:52 +0100
commit971f135c0d49c8418369d894d5496461b96db9de (patch)
tree87fedf80d7fdf14027185142e1ed141c2c36f009 /ranger
parent5149d6a5a03ec0dc831c75a895f6b9b2ef8efe68 (diff)
downloadranger-971f135c0d49c8418369d894d5496461b96db9de.tar.gz
Rotate the images according to the EXIF data
Fixes #927.
Diffstat (limited to 'ranger')
-rwxr-xr-xranger/data/scope.sh9
1 files changed, 9 insertions, 0 deletions
diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh
index 8386eac2..3bf5785a 100755
--- a/ranger/data/scope.sh
+++ b/ranger/data/scope.sh
@@ -95,6 +95,15 @@ handle_image() {
 
         # Image
         image/*)
+            local orientation
+            orientation="$( identify -format '%[EXIF:Orientation]\n' -- "${FILE_PATH}" )"
+            # If orientation data is present and the image actually
+            # needs rotating ("1" means no rotation)...
+            if [[ -n "$orientation" && "$orientation" != 1 ]]; then
+                # ...auto-rotate the image according to the EXIF data.
+                convert -- "${FILE_PATH}" -auto-orient "${IMAGE_CACHE_PATH}" && exit 6
+            fi
+
             # `w3mimgdisplay` will be called for all images (unless overriden as above),
             # but might fail for unsupported types.
             exit 7;;