From 7fbd8d9feeaf2ce5823e31ba49ef0f72fd38c18e Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 21 Mar 2013 20:59:06 +0100 Subject: autorotate images based on EXIF orientation (with exif=1) --- src/imlib.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/imlib.c b/src/imlib.c index 5514a34..42d9711 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -233,6 +233,10 @@ int feh_load_image(Imlib_Image * im, feh_file * file) char *tmpname = NULL; char *real_filename = NULL; +#ifdef HAVE_LIBEXIF + ExifEntry *entry; +#endif + D(("filename is %s, image is %p\n", file->filename, im)); if (!file || !file->filename) @@ -284,7 +288,19 @@ int feh_load_image(Imlib_Image * im, feh_file * file) #ifdef HAVE_LIBEXIF file->ed = exif_get_data(file->filename); -#endif + + if (file->ed) { + entry = exif_content_get_entry(file->ed->ifd[EXIF_IFD_0], 0x0112); + if (entry != NULL) { + if (*(entry->data) == 3) + gib_imlib_image_orientate(*im, 2); + else if (*(entry->data) == 6) + gib_imlib_image_orientate(*im, 1); + else if (*(entry->data) == 8) + gib_imlib_image_orientate(*im, 3); + } + } +#endif D(("Loaded ok\n")); return(1); -- cgit v1.2.3