From 66b581330ee0517e346170a3695c3b53a32a0c18 Mon Sep 17 00:00:00 2001 From: Elliot Wolk Date: Sat, 29 Oct 2016 04:56:13 -0400 Subject: imlib: fix autorotate EXIF parsing --- src/imlib.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'src/imlib.c') diff --git a/src/imlib.c b/src/imlib.c index 16fbfba..1cf2e5b 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -258,22 +258,25 @@ int feh_load_image(Imlib_Image * im, feh_file * file) return(0); } + int orientation = 0; #ifdef HAVE_LIBEXIF - file->ed = exif_get_data(file->filename); - - 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); - } + ExifData *exifData = exif_data_new_from_file(file->filename); + if (exifData) { + ExifByteOrder byteOrder = exif_data_get_byte_order(exifData); + ExifEntry *exifEntry = exif_data_get_entry(exifData, EXIF_TAG_ORIENTATION); + if (exifEntry) + orientation = exif_get_short(exifEntry->data, byteOrder); } + file->ed = exifData; #endif + if (orientation == 3) + gib_imlib_image_orientate(*im, 2); + else if (orientation == 6) + gib_imlib_image_orientate(*im, 1); + else if (orientation == 8) + gib_imlib_image_orientate(*im, 3); + D(("Loaded ok\n")); return(1); } -- cgit v1.2.3