[nautilus] image properties: Handle rotated images



commit 0645e3b9aaf8661991a89dfab8774146120e9146
Author: James Westman <james flyingpimonster net>
Date:   Wed Sep 2 14:50:35 2020 -0500

    image properties: Handle rotated images
    
    Images with EXIF metadata can contain an orientation tag, which indicates the
    image should be rotated. In the Image tab of the Properties dialog, swap the
    width and height if the image is rotated by 90 or 270 degrees.
    
    Fixes #1590.

 .../nautilus-image-properties-page.c               | 27 ++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)
---
diff --git a/extensions/image-properties/nautilus-image-properties-page.c 
b/extensions/image-properties/nautilus-image-properties-page.c
index bca0b56e8..23aca4986 100644
--- a/extensions/image-properties/nautilus-image-properties-page.c
+++ b/extensions/image-properties/nautilus-image-properties-page.c
@@ -136,6 +136,9 @@ static void
 append_basic_info (NautilusImagesPropertiesPage *page)
 {
     GdkPixbufFormat *format;
+    GExiv2Orientation orientation;
+    int width;
+    int height;
     g_autofree char *name = NULL;
     g_autofree char *desc = NULL;
     g_autofree char *value = NULL;
@@ -147,19 +150,35 @@ append_basic_info (NautilusImagesPropertiesPage *page)
 
     append_item (page, _("Image Type"), value);
 
+    orientation = gexiv2_metadata_get_orientation (page->md);
+
+    if (orientation == GEXIV2_ORIENTATION_ROT_90
+        || orientation == GEXIV2_ORIENTATION_ROT_270
+        || orientation == GEXIV2_ORIENTATION_ROT_90_HFLIP
+        || orientation == GEXIV2_ORIENTATION_ROT_90_VFLIP)
+    {
+        width = page->height;
+        height = page->width;
+    }
+    else
+    {
+        width = page->width;
+        height = page->height;
+    }
+
     g_free (value);
     value = g_strdup_printf (ngettext ("%d pixel",
                                        "%d pixels",
-                                       page->width),
-                             page->width);
+                                       width),
+                             width);
 
     append_item (page, _("Width"), value);
 
     g_free (value);
     value = g_strdup_printf (ngettext ("%d pixel",
                                        "%d pixels",
-                                       page->height),
-                             page->height);
+                                       height),
+                             height);
 
     append_item (page, _("Height"), value);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]