Krolyxon
Commit ef0ed32

Branches

Refs →

nsxivef0ed32

Removed exif support; made gif support non-optional

Author
Bert Münnich
Date
2012-02-11 02:42 +0100
Parent
c3c95ab
Commit
ef0ed3226428c00507e76bdda77c522729ed6809

+16 −160

7 files changed

  1. M Makefile +5 −8
  2. M README.md +7 −12
  3. D config.c +0 −38
  4. M config.def.h +0 −12
  5. M image.c +3 −67
  6. M options.c +0 −13
  7. M thumbs.c +1 −10
M Makefile View
@@ -3,7 +3,7 @@ VERSION = git-20120211
33 CC = gcc
44 CFLAGS = -ansi -Wall -pedantic -O2
55 LDFLAGS =
6−LIBS = -lX11 -lImlib2
6+LIBS = -lX11 -lImlib2 -lgif
77
88 PREFIX = /usr/local
99 MANPREFIX = $(PREFIX)/share/man
@@ -24,22 +24,19 @@ options:
2424 @echo "CC $<"
2525 @$(CC) $(CFLAGS) -DVERSION=\"$(VERSION)\" -c -o $@ $<
2626
27−$(OBJ) config: Makefile config.h
28−
29−config: config.c
30− @$(CC) $(CFLAGS) -o $@ $@.c
27+$(OBJ): Makefile config.h
3128
3229 config.h:
3330 @echo "creating $@ from config.def.h"
3431 @cp config.def.h $@
3532
36−sxiv: $(OBJ) config
33+sxiv: $(OBJ)
3734 @echo "CC -o $@"
38− @$(CC) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) $$(./config -l)
35+ @$(CC) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
3936
4037 clean:
4138 @echo "cleaning"
42− @rm -f $(OBJ) config sxiv sxiv-$(VERSION).tar.gz
39+ @rm -f $(OBJ) sxiv sxiv-$(VERSION).tar.gz
4340
4441 install: all
4542 @echo "installing executable file to $(DESTDIR)$(PREFIX)/bin"
M README.md View
@@ -1,11 +1,11 @@
11 sxiv: Simple (or small or suckless) X Image Viewer
22
3−sxiv is an alternative to feh and qiv. Its only dependency besides xlib is
4−imlib2. The primary goal for writing sxiv is to create an image viewer, which
5−only has the most basic features required for fast image viewing (the ones I
6−want). It has vi key bindings and works nicely with tiling window managers.
7−Its code base should be kept small and clean to make it easy for you to dig
8−into it and customize it for your needs.
3+sxiv is an alternative to feh and qiv. Its only dependencies besides xlib are
4+imlib2 and giflib. The primary goal for writing sxiv is to create an image
5+viewer, which only has the most basic features required for fast image viewing
6+(the ones I want). It has vi key bindings and works nicely with tiling window
7+managers. Its code base should be kept small and clean to make it easy for you
8+to dig into it and customize it for your needs.
99
1010 Features
1111 --------
@@ -15,14 +15,9 @@ Features
1515 * Thumbnail mode: grid of selectable previews of all images
1616 * Ability to cache thumbnails for fast re-loading
1717 * Basic support for multi-frame images
18+* Load all frames from GIF files and play GIF animations
1819 * Display image information in window title
1920
20−Additional features, that need to be enabled at compile-time (in *config.h*),
21−because they depend on additional libraries:
22−
23−* Load all frames from GIF files and play GIF animations (requires giflib)
24−* Auto-orientate JPEG images according to their EXIF tags (requires libexif)
25−
2621 Screenshots
2722 -----------
2823
D config.c View
@@ -1,38 +0,0 @@
1−#define _POSIX_C_SOURCE 200112L
2−#define _FEATURE_CONFIG
3−
4−#include <stdio.h>
5−
6−#include "config.h"
7−
8−#define QUOTE(m) #m
9−#define PUT_MACRO(m) \
10− printf(" -D%s=%s", #m, QUOTE(m))
11−
12−int puts_if(const char *s, int c) {
13− return c ? printf(" %s", s) : 0;
14−}
15−
16−int main(int argc, char **argv) {
17− int i;
18− unsigned int n = 0;
19−
20− for (i = 1; i < argc; i++) {
21− switch ((argv[i][0] != '-' || argv[i][2] != '\0') ? -1 : argv[i][1]) {
22− case 'D':
23− n += PUT_MACRO(EXIF_SUPPORT);
24− n += PUT_MACRO(GIF_SUPPORT);
25− break;
26− case 'l':
27− n += puts_if("-lexif", EXIF_SUPPORT);
28− n += puts_if("-lgif", GIF_SUPPORT);
29− break;
30− default:
31− fprintf(stderr, "%s: invalid argument: %s\n", argv[0], argv[i]);
32− return 1;
33− }
34− }
35− if (n > 0)
36− printf("\n");
37− return 0;
38−}
M config.def.h View
@@ -1,15 +1,3 @@
1−#ifdef _FEATURE_CONFIG
2−
3−/* auto-orientate jpeg files according to their exif tags?
4− * (requires libexif [-lexif] to be installed)
5− */
6−#define EXIF_SUPPORT 0
7−/* load all frames from gif files and support gif animations?
8− * (requires giflib [-lgif] to be installed)
9− */
10−#define GIF_SUPPORT 0
11−
12−#endif
131 #ifdef _WINDOW_CONFIG
142
153 /* default window dimensions (overwritten via -g option): */
M image.c View
@@ -17,27 +17,19 @@
1717 */
1818
1919 #define _POSIX_C_SOURCE 200112L
20−#define _FEATURE_CONFIG
2120 #define _IMAGE_CONFIG
2221
22+#include <stdlib.h>
2323 #include <string.h>
24+#include <sys/types.h>
2425 #include <unistd.h>
26+#include <gif_lib.h>
2527
2628 #include "image.h"
2729 #include "options.h"
2830 #include "util.h"
2931 #include "config.h"
3032
31−#if EXIF_SUPPORT
32−#include <libexif/exif-data.h>
33−#endif
34−
35−#if GIF_SUPPORT
36−#include <stdlib.h>
37−#include <sys/types.h>
38−#include <gif_lib.h>
39−#endif
40−
4133 enum { MIN_GIF_DELAY = 50 };
4234
4335 float zoom_min;
@@ -72,55 +64,6 @@ void img_init(img_t *img, win_t *win) {
7264 img->multi.animate = false;
7365 }
7466
75−#if EXIF_SUPPORT
76−void exif_auto_orientate(const fileinfo_t *file) {
77− ExifData *ed;
78− ExifEntry *entry;
79− int byte_order, orientation;
80−
81− if ((ed = exif_data_new_from_file(file->path)) == NULL)
82− return;
83− entry = exif_content_get_entry(ed->ifd[EXIF_IFD_0], EXIF_TAG_ORIENTATION);
84− if (entry != NULL) {
85− byte_order = exif_data_get_byte_order(ed);
86− orientation = exif_get_short(entry->data, byte_order);
87− }
88− exif_data_unref(ed);
89− if (entry == NULL)
90− return;
91−
92− switch (orientation) {
93− case 5:
94− imlib_image_orientate(1);
95− case 2:
96− imlib_image_flip_vertical();
97− break;
98−
99− case 3:
100− imlib_image_orientate(2);
101− break;
102−
103− case 7:
104− imlib_image_orientate(1);
105− case 4:
106− imlib_image_flip_horizontal();
107− break;
108−
109− case 6:
110− imlib_image_orientate(1);
111− break;
112−
113− case 8:
114− imlib_image_orientate(3);
115− break;
116− }
117−}
118−#endif /* EXIF_SUPPORT */
119−
120−#if GIF_SUPPORT
121−/* Originally based on, but in its current form merely inspired by Imlib2's
122− * src/modules/loaders/loader_gif.c:load(), written by Carsten Haitzler.
123− */
12467 bool img_load_gif(img_t *img, const fileinfo_t *file) {
12568 GifFileType *gif;
12669 GifRowType *rows = NULL;
@@ -290,7 +233,6 @@ bool img_load_gif(img_t *img, const fileinfo_t *file) {
290233
291234 return !err;
292235 }
293−#endif /* GIF_SUPPORT */
294236
295237 bool img_load(img_t *img, const fileinfo_t *file) {
296238 const char *fmt;
@@ -312,14 +254,8 @@ bool img_load(img_t *img, const fileinfo_t *file) {
312254 warn("could not open image: %s", file->name);
313255 return false;
314256 }
315−#if EXIF_SUPPORT
316− if (STREQ(fmt, "jpeg"))
317− exif_auto_orientate(file);
318−#endif
319−#if GIF_SUPPORT
320257 if (STREQ(fmt, "gif"))
321258 img_load_gif(img, file);
322−#endif
323259
324260 img->w = imlib_image_get_width();
325261 img->h = imlib_image_get_height();
M options.c View
@@ -17,7 +17,6 @@
1717 */
1818
1919 #define _POSIX_C_SOURCE 200112L
20−#define _FEATURE_CONFIG
2120 #define _IMAGE_CONFIG
2221
2322 #include <stdlib.h>
@@ -39,18 +38,6 @@ void print_usage(void) {
3938
4039 void print_version(void) {
4140 printf("sxiv %s - Simple X Image Viewer\n", VERSION);
42− printf("Additional features included (+) or not (-): %s, %s\n",
43−#if EXIF_SUPPORT
44− "+exif",
45−#else
46− "-exif",
47−#endif
48−#if GIF_SUPPORT
49− "+gif"
50−#else
51− "-gif"
52−#endif
53− );
5441 }
5542
5643 void parse_options(int argc, char **argv) {
M thumbs.c View
@@ -17,7 +17,6 @@
1717 */
1818
1919 #define _POSIX_C_SOURCE 200112L
20−#define _FEATURE_CONFIG
2120 #define _THUMBS_CONFIG
2221
2322 #include <stdlib.h>
@@ -31,10 +30,6 @@
3130 #include "util.h"
3231 #include "config.h"
3332
34−#if EXIF_SUPPORT
35−void exif_auto_orientate(const fileinfo_t*);
36−#endif
37−
3833 const int thumb_dim = THUMB_SIZE + 10;
3934 char *cache_dir = NULL;
4035
@@ -211,7 +206,7 @@ void tns_free(tns_t *tns) {
211206 }
212207
213208 bool tns_load(tns_t *tns, int n, const fileinfo_t *file,
214− bool force, bool silent)
209+ bool force, bool silent)
215210 {
216211 int w, h;
217212 bool use_cache, cache_hit = false;
@@ -259,10 +254,6 @@ bool tns_load(tns_t *tns, int n, const fileinfo_t *file,
259254 imlib_free_image_and_decache();
260255 return false;
261256 }
262−#if EXIF_SUPPORT
263− if (!cache_hit && STREQ(fmt, "jpeg"))
264− exif_auto_orientate(file);
265−#endif
266257
267258 w = imlib_image_get_width();
268259 h = imlib_image_get_height();