summaryrefslogtreecommitdiff
path: root/src/imlib.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/imlib.c')
-rw-r--r--src/imlib.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/imlib.c b/src/imlib.c
index 16fbfba..193f5f8 100644
--- a/src/imlib.c
+++ b/src/imlib.c
@@ -259,19 +259,22 @@ int feh_load_image(Imlib_Image * im, feh_file * file)
}
#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);
- }
+ int orientation = 0;
+ 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 && opt.auto_rotate)
+ orientation = exif_get_short(exifEntry->data, byteOrder);
}
+ file->ed = exifData;
+
+ 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);
#endif
D(("Loaded ok\n"));