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') 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 From 868fdddb3882036ed5676ebb8192f95dd0708752 Mon Sep 17 00:00:00 2001 From: Elliot Wolk Date: Sat, 29 Oct 2016 14:05:36 -0400 Subject: add cmdline opt --auto-rotate to rotate according to EXIF info --- src/help.raw | 1 + src/imlib.c | 2 +- src/options.c | 4 ++++ src/options.h | 1 + 4 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/help.raw b/src/help.raw index 03c8348..067e35f 100644 --- a/src/help.raw +++ b/src/help.raw @@ -35,6 +35,7 @@ OPTIONS -d, --draw-filename Show the filename in the image window --draw-tinted Show overlay texts on semi-transparent background --draw-exif Show some Exif information (if compiled with exif=1) + --auto-rotate Rotate images according to Exif info (if compiled with exif=1) -^, --title TITLE Set window title (see FORMAT SPECIFIERS) -D, --slideshow-delay NUM Set delay between automatically changing slides --cycle-once Exit after one loop through the slideshow diff --git a/src/imlib.c b/src/imlib.c index 1cf2e5b..fd78d0c 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -264,7 +264,7 @@ int feh_load_image(Imlib_Image * im, feh_file * file) if (exifData) { ExifByteOrder byteOrder = exif_data_get_byte_order(exifData); ExifEntry *exifEntry = exif_data_get_entry(exifData, EXIF_TAG_ORIENTATION); - if (exifEntry) + if (exifEntry && opt.auto_rotate) orientation = exif_get_short(exifEntry->data, byteOrder); } file->ed = exifData; diff --git a/src/options.c b/src/options.c index 9e2ff5a..56323a8 100644 --- a/src/options.c +++ b/src/options.c @@ -396,6 +396,7 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) {"no-jump-on-resort", 0, 0, 220}, #ifdef HAVE_LIBEXIF {"draw-exif" , 0, 0, 223}, + {"auto-rotate" , 0, 0, 242}, #endif {"cycle-once" , 0, 0, 224}, {"no-xinerama" , 0, 0, 225}, @@ -730,6 +731,9 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) case 223: opt.draw_exif = 1; break; + case 242: + opt.auto_rotate = 1; + break; #endif case 224: opt.cycle_once = 1; diff --git a/src/options.h b/src/options.h index c7ce689..5a5ce84 100644 --- a/src/options.h +++ b/src/options.h @@ -51,6 +51,7 @@ struct __fehoptions { unsigned char draw_filename; #ifdef HAVE_LIBEXIF unsigned char draw_exif; + unsigned char auto_rotate; #endif unsigned char list; unsigned char quiet; -- cgit v1.2.3 From f850bc191dbac45cdd3f39548b65a0f0e390bbb8 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 30 Oct 2016 10:40:37 +0100 Subject: imlib.c: Move orientation logic inside HAVE_LIBEXIF --- src/imlib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/imlib.c b/src/imlib.c index fd78d0c..193f5f8 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -258,8 +258,8 @@ int feh_load_image(Imlib_Image * im, feh_file * file) return(0); } - int orientation = 0; #ifdef HAVE_LIBEXIF + int orientation = 0; ExifData *exifData = exif_data_new_from_file(file->filename); if (exifData) { ExifByteOrder byteOrder = exif_data_get_byte_order(exifData); @@ -268,7 +268,6 @@ int feh_load_image(Imlib_Image * im, feh_file * file) orientation = exif_get_short(exifEntry->data, byteOrder); } file->ed = exifData; -#endif if (orientation == 3) gib_imlib_image_orientate(*im, 2); @@ -276,6 +275,7 @@ int feh_load_image(Imlib_Image * im, feh_file * file) gib_imlib_image_orientate(*im, 1); else if (orientation == 8) gib_imlib_image_orientate(*im, 3); +#endif D(("Loaded ok\n")); return(1); -- cgit v1.2.3