Skip to content

Commit b70d85e

Browse files
Neil Mulleremersion
authored andcommitted
Correct for image orientation when loading image
PEG 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. Pulled from swaywm/swaybg#68
1 parent f9ce3f1 commit b70d85e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

background-image.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,12 @@ cairo_surface_t *load_background_image(const char *path) {
3131
err->message);
3232
return NULL;
3333
}
34-
image = gdk_cairo_image_surface_create_from_pixbuf(pixbuf);
34+
// Correct for embedded image orientation; typical images are not
35+
// rotated and will be handled efficiently
36+
GdkPixbuf *oriented = gdk_pixbuf_apply_embedded_orientation(pixbuf);
3537
g_object_unref(pixbuf);
38+
image = gdk_cairo_image_surface_create_from_pixbuf(oriented);
39+
g_object_unref(oriented);
3640
#else
3741
image = cairo_image_surface_create_from_png(path);
3842
#endif // HAVE_GDK_PIXBUF

0 commit comments

Comments
 (0)