diff options
author | James Westman <james@flyingpimonster.net> | 2020-09-02 14:50:35 -0500 |
---|---|---|
committer | Ondrej Holy <oholy@redhat.com> | 2020-11-18 15:17:43 +0000 |
commit | 0645e3b9aaf8661991a89dfab8774146120e9146 (patch) | |
tree | f250b0ec076ba05e6504810ec61353e59a6c3528 | |
parent | 9dbc32ded35688571eb9104bdc46a64c7578dfee (diff) | |
download | nautilus-0645e3b9aaf8661991a89dfab8774146120e9146.tar.gz |
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.
-rw-r--r-- | extensions/image-properties/nautilus-image-properties-page.c | 27 |
1 files 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); } |