summaryrefslogtreecommitdiffstats
path: root/image.c
diff options
context:
space:
mode:
authorBert Münnich <ber.t@posteo.de>2014-06-09 22:59:49 +0200
committerBert Münnich <ber.t@posteo.de>2014-06-09 22:59:49 +0200
commitd26f39914e813aff492020b3d8463965ca8ca574 (patch)
treeb44f39fc050492a0cb964bd74aac3b2bdce64857 /image.c
parent0f7b26d33d29b9654ccf3c80a8bd5e57720cfcc1 (diff)
downloadnsxiv-d26f39914e813aff492020b3d8463965ca8ca574.tar.zst
Use thumbnails in EXIF tags; requirement for libexif is back
Diffstat (limited to 'image.c')
-rw-r--r--image.c48
1 files changed, 32 insertions, 16 deletions
diff --git a/image.c b/image.c
index 7eec544..7312e73 100644
--- a/image.c
+++ b/image.c
@@ -24,17 +24,20 @@
#include <sys/types.h>
#include <unistd.h>
-#if HAVE_GIFLIB
-#include <gif_lib.h>
-enum { MIN_GIF_DELAY = 25 };
-#endif
-
-#include "exif.h"
#include "image.h"
#include "options.h"
#include "util.h"
#include "config.h"
+#if HAVE_LIBEXIF
+#include <libexif/exif-data.h>
+#endif
+
+#if HAVE_GIFLIB
+#include <gif_lib.h>
+enum { MIN_GIF_DELAY = 25 };
+#endif
+
float zoom_min;
float zoom_max;
@@ -92,9 +95,22 @@ void img_init(img_t *img, win_t *win)
img->ss.delay = options->slideshow > 0 ? options->slideshow : SLIDESHOW_DELAY;
}
+#if HAVE_LIBEXIF
void exif_auto_orientate(const fileinfo_t *file)
{
- switch (exif_orientation(file)) {
+ ExifData *ed;
+ ExifEntry *entry;
+ int byte_order, orientation = 0;
+
+ if ((ed = exif_data_new_from_file(file->path)) == NULL)
+ return;
+ byte_order = exif_data_get_byte_order(ed);
+ entry = exif_content_get_entry(ed->ifd[EXIF_IFD_0], EXIF_TAG_ORIENTATION);
+ if (entry != NULL)
+ orientation = exif_get_short(entry->data, byte_order);
+ exif_data_unref(ed);
+
+ switch (orientation) {
case 5:
imlib_image_orientate(1);
case 2:
@@ -116,6 +132,7 @@ void exif_auto_orientate(const fileinfo_t *file)
break;
}
}
+#endif
#if HAVE_GIFLIB
bool img_load_gif(img_t *img, const fileinfo_t *file)
@@ -322,17 +339,16 @@ bool img_load(img_t *img, const fileinfo_t *file)
imlib_context_set_image(img->im);
imlib_image_set_changes_on_disk();
- if ((fmt = imlib_image_format()) == NULL) {
- warn("could not open image: %s", file->name);
- return false;
- }
- if (STREQ(fmt, "jpeg"))
- exif_auto_orientate(file);
-#if HAVE_GIFLIB
- if (STREQ(fmt, "gif"))
- img_load_gif(img, file);
+#if HAVE_LIBEXIF
+ exif_auto_orientate(file);
#endif
+ if ((fmt = imlib_image_format()) != NULL) {
+#if HAVE_GIFLIB
+ if (STREQ(fmt, "gif"))
+ img_load_gif(img, file);
+#endif
+ }
img_apply_gamma(img);
img->w = imlib_image_get_width();