Added EXIF_SUPPORT macro for optional dependency on libexif

This commit is contained in:
Bert 2011-09-08 15:55:03 +02:00
parent bfab4dc328
commit fdbc5cf76b
2 changed files with 42 additions and 30 deletions

57
image.c
View file

@ -18,7 +18,10 @@
#include <string.h>
#include <unistd.h>
#ifdef EXIF_SUPPORT
#include <libexif/exif-data.h>
#endif
#ifdef GIF_SUPPORT
#include <stdlib.h>
@ -38,6 +41,29 @@ enum { MIN_GIF_DELAY = 50 };
float zoom_min;
float zoom_max;
void img_init(img_t *img, win_t *win) {
zoom_min = zoom_levels[0] / 100.0;
zoom_max = zoom_levels[ARRLEN(zoom_levels) - 1] / 100.0;
if (img) {
img->im = NULL;
img->multi.cap = img->multi.cnt = 0;
img->multi.animate = 0;
img->zoom = options->zoom;
img->zoom = MAX(img->zoom, zoom_min);
img->zoom = MIN(img->zoom, zoom_max);
img->aa = options->aa;
img->alpha = 1;
}
if (win) {
imlib_context_set_display(win->env.dpy);
imlib_context_set_visual(win->env.vis);
imlib_context_set_colormap(win->env.cmap);
}
}
#ifdef EXIF_SUPPORT
void exif_auto_orientate(const fileinfo_t *file) {
ExifData *ed;
ExifEntry *entry;
@ -80,28 +106,7 @@ void exif_auto_orientate(const fileinfo_t *file) {
break;
}
}
void img_init(img_t *img, win_t *win) {
zoom_min = zoom_levels[0] / 100.0;
zoom_max = zoom_levels[ARRLEN(zoom_levels) - 1] / 100.0;
if (img) {
img->im = NULL;
img->multi.cap = img->multi.cnt = 0;
img->multi.animate = 0;
img->zoom = options->zoom;
img->zoom = MAX(img->zoom, zoom_min);
img->zoom = MIN(img->zoom, zoom_max);
img->aa = options->aa;
img->alpha = 1;
}
if (win) {
imlib_context_set_display(win->env.dpy);
imlib_context_set_visual(win->env.vis);
imlib_context_set_colormap(win->env.cmap);
}
}
#endif /* EXIF_SUPPORT */
#ifdef GIF_SUPPORT
/* Originally based on, but in its current form merely inspired by Imlib2's
@ -285,14 +290,16 @@ int img_load(img_t *img, const fileinfo_t *file) {
imlib_context_set_anti_alias(img->aa);
fmt = imlib_image_format();
/* avoid unused-but-set-variable warning */
(void) fmt;
#ifdef EXIF_SUPPORT
if (!strcmp(fmt, "jpeg"))
exif_auto_orientate(file);
#endif
#ifdef GIF_SUPPORT
if (!strcmp(fmt, "gif"))
img_load_gif(img, file);
#else
/* avoid unused-but-set-variable warning */
(void) fmt;
#endif
img->scalemode = options->scalemode;

View file

@ -34,7 +34,9 @@
#define st_atim st_atimespec
#endif
#ifdef EXIF_SUPPORT
void exif_auto_orientate(const fileinfo_t*);
#endif
const int thumb_dim = THUMB_SIZE + 10;
char *cache_dir = NULL;
@ -255,11 +257,14 @@ int tns_load(tns_t *tns, int n, const fileinfo_t *file,
imlib_context_set_image(im);
imlib_context_set_anti_alias(1);
if (!cache_hit) {
fmt = imlib_image_format();
if (!strcmp(fmt, "jpeg"))
exif_auto_orientate(file);
}
fmt = imlib_image_format();
/* avoid unused-but-set-variable warning */
(void) fmt;
#ifdef EXIF_SUPPORT
if (!cache_hit !strcmp(fmt, "jpeg"))
exif_auto_orientate(file);
#endif
w = imlib_image_get_width();
h = imlib_image_get_height();