diff options
author | Manuel Stoeckl <code@mstoeckl.com> | 2024-04-15 19:51:43 -0400 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2024-04-16 10:33:36 +0200 |
commit | b4fda8146ceb006179e19ed7dd15ee713d493e4b (patch) | |
tree | 56ebdd80a1117d0b25beb06866ab14354a2e6959 /background-image.c | |
parent | 87ca82d8872b4f5768419ac0c4f951f9da17619d (diff) | |
download | swaybg-b4fda8146ceb006179e19ed7dd15ee713d493e4b.tar.gz swaybg-b4fda8146ceb006179e19ed7dd15ee713d493e4b.tar.bz2 |
Correct for image orientation when loading image
JPEG and other image formats may include an EXIF orientation tag
which indicates in what orientation (rotation and mirroring)
the image should be displayed. libgdk-pixbuf does not correct for this
when loading an image, but provides a function to apply the transform
after the fact, which this commit uses.
Diffstat (limited to 'background-image.c')
-rw-r--r-- | background-image.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/background-image.c b/background-image.c index 53d1b63..3eae832 100644 --- a/background-image.c +++ b/background-image.c @@ -31,8 +31,12 @@ cairo_surface_t *load_background_image(const char *path) { err->message); return NULL; } - image = gdk_cairo_image_surface_create_from_pixbuf(pixbuf); + // Correct for embedded image orientation; typical images are not + // rotated and will be handled efficiently + GdkPixbuf *oriented = gdk_pixbuf_apply_embedded_orientation(pixbuf); g_object_unref(pixbuf); + image = gdk_cairo_image_surface_create_from_pixbuf(oriented); + g_object_unref(oriented); #else image = cairo_image_surface_create_from_png(path); #endif // HAVE_GDK_PIXBUF |