@@ -3,7 +3,7 @@ VERSION = git-20120211 | |||
CC = gcc | |||
CFLAGS = -ansi -Wall -pedantic -O2 | |||
LDFLAGS = | |||
LIBS = -lX11 -lImlib2 | |||
LIBS = -lX11 -lImlib2 -lgif | |||
PREFIX = /usr/local | |||
MANPREFIX = $(PREFIX)/share/man | |||
@@ -24,22 +24,19 @@ options: | |||
@echo "CC $<" | |||
@$(CC) $(CFLAGS) -DVERSION=\"$(VERSION)\" -c -o $@ $< | |||
$(OBJ) config: Makefile config.h | |||
config: config.c | |||
@$(CC) $(CFLAGS) -o $@ $@.c | |||
$(OBJ): Makefile config.h | |||
config.h: | |||
@echo "creating $@ from config.def.h" | |||
@cp config.def.h $@ | |||
sxiv: $(OBJ) config | |||
sxiv: $(OBJ) | |||
@echo "CC -o $@" | |||
@$(CC) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) $$(./config -l) | |||
@$(CC) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) | |||
clean: | |||
@echo "cleaning" | |||
@rm -f $(OBJ) config sxiv sxiv-$(VERSION).tar.gz | |||
@rm -f $(OBJ) sxiv sxiv-$(VERSION).tar.gz | |||
install: all | |||
@echo "installing executable file to $(DESTDIR)$(PREFIX)/bin" | |||
@@ -1,11 +1,11 @@ | |||
sxiv: Simple (or small or suckless) X Image Viewer | |||
sxiv is an alternative to feh and qiv. Its only dependency besides xlib is | |||
imlib2. The primary goal for writing sxiv is to create an image viewer, which | |||
only has the most basic features required for fast image viewing (the ones I | |||
want). It has vi key bindings and works nicely with tiling window managers. | |||
Its code base should be kept small and clean to make it easy for you to dig | |||
into it and customize it for your needs. | |||
sxiv is an alternative to feh and qiv. Its only dependencies besides xlib are | |||
imlib2 and giflib. The primary goal for writing sxiv is to create an image | |||
viewer, which only has the most basic features required for fast image viewing | |||
(the ones I want). It has vi key bindings and works nicely with tiling window | |||
managers. Its code base should be kept small and clean to make it easy for you | |||
to dig into it and customize it for your needs. | |||
Features | |||
-------- | |||
@@ -15,14 +15,9 @@ Features | |||
* Thumbnail mode: grid of selectable previews of all images | |||
* Ability to cache thumbnails for fast re-loading | |||
* Basic support for multi-frame images | |||
* Load all frames from GIF files and play GIF animations | |||
* Display image information in window title | |||
Additional features, that need to be enabled at compile-time (in *config.h*), | |||
because they depend on additional libraries: | |||
* Load all frames from GIF files and play GIF animations (requires giflib) | |||
* Auto-orientate JPEG images according to their EXIF tags (requires libexif) | |||
Screenshots | |||
----------- | |||
@@ -1,38 +0,0 @@ | |||
#define _POSIX_C_SOURCE 200112L | |||
#define _FEATURE_CONFIG | |||
#include <stdio.h> | |||
#include "config.h" | |||
#define QUOTE(m) #m | |||
#define PUT_MACRO(m) \ | |||
printf(" -D%s=%s", #m, QUOTE(m)) | |||
int puts_if(const char *s, int c) { | |||
return c ? printf(" %s", s) : 0; | |||
} | |||
int main(int argc, char **argv) { | |||
int i; | |||
unsigned int n = 0; | |||
for (i = 1; i < argc; i++) { | |||
switch ((argv[i][0] != '-' || argv[i][2] != '\0') ? -1 : argv[i][1]) { | |||
case 'D': | |||
n += PUT_MACRO(EXIF_SUPPORT); | |||
n += PUT_MACRO(GIF_SUPPORT); | |||
break; | |||
case 'l': | |||
n += puts_if("-lexif", EXIF_SUPPORT); | |||
n += puts_if("-lgif", GIF_SUPPORT); | |||
break; | |||
default: | |||
fprintf(stderr, "%s: invalid argument: %s\n", argv[0], argv[i]); | |||
return 1; | |||
} | |||
} | |||
if (n > 0) | |||
printf("\n"); | |||
return 0; | |||
} |
@@ -1,15 +1,3 @@ | |||
#ifdef _FEATURE_CONFIG | |||
/* auto-orientate jpeg files according to their exif tags? | |||
* (requires libexif [-lexif] to be installed) | |||
*/ | |||
#define EXIF_SUPPORT 0 | |||
/* load all frames from gif files and support gif animations? | |||
* (requires giflib [-lgif] to be installed) | |||
*/ | |||
#define GIF_SUPPORT 0 | |||
#endif | |||
#ifdef _WINDOW_CONFIG | |||
/* default window dimensions (overwritten via -g option): */ | |||
@@ -17,27 +17,19 @@ | |||
*/ | |||
#define _POSIX_C_SOURCE 200112L | |||
#define _FEATURE_CONFIG | |||
#define _IMAGE_CONFIG | |||
#include <stdlib.h> | |||
#include <string.h> | |||
#include <sys/types.h> | |||
#include <unistd.h> | |||
#include <gif_lib.h> | |||
#include "image.h" | |||
#include "options.h" | |||
#include "util.h" | |||
#include "config.h" | |||
#if EXIF_SUPPORT | |||
#include <libexif/exif-data.h> | |||
#endif | |||
#if GIF_SUPPORT | |||
#include <stdlib.h> | |||
#include <sys/types.h> | |||
#include <gif_lib.h> | |||
#endif | |||
enum { MIN_GIF_DELAY = 50 }; | |||
float zoom_min; | |||
@@ -72,55 +64,6 @@ void img_init(img_t *img, win_t *win) { | |||
img->multi.animate = false; | |||
} | |||
#if EXIF_SUPPORT | |||
void exif_auto_orientate(const fileinfo_t *file) { | |||
ExifData *ed; | |||
ExifEntry *entry; | |||
int byte_order, orientation; | |||
if ((ed = exif_data_new_from_file(file->path)) == NULL) | |||
return; | |||
entry = exif_content_get_entry(ed->ifd[EXIF_IFD_0], EXIF_TAG_ORIENTATION); | |||
if (entry != NULL) { | |||
byte_order = exif_data_get_byte_order(ed); | |||
orientation = exif_get_short(entry->data, byte_order); | |||
} | |||
exif_data_unref(ed); | |||
if (entry == NULL) | |||
return; | |||
switch (orientation) { | |||
case 5: | |||
imlib_image_orientate(1); | |||
case 2: | |||
imlib_image_flip_vertical(); | |||
break; | |||
case 3: | |||
imlib_image_orientate(2); | |||
break; | |||
case 7: | |||
imlib_image_orientate(1); | |||
case 4: | |||
imlib_image_flip_horizontal(); | |||
break; | |||
case 6: | |||
imlib_image_orientate(1); | |||
break; | |||
case 8: | |||
imlib_image_orientate(3); | |||
break; | |||
} | |||
} | |||
#endif /* EXIF_SUPPORT */ | |||
#if GIF_SUPPORT | |||
/* Originally based on, but in its current form merely inspired by Imlib2's | |||
* src/modules/loaders/loader_gif.c:load(), written by Carsten Haitzler. | |||
*/ | |||
bool img_load_gif(img_t *img, const fileinfo_t *file) { | |||
GifFileType *gif; | |||
GifRowType *rows = NULL; | |||
@@ -290,7 +233,6 @@ bool img_load_gif(img_t *img, const fileinfo_t *file) { | |||
return !err; | |||
} | |||
#endif /* GIF_SUPPORT */ | |||
bool img_load(img_t *img, const fileinfo_t *file) { | |||
const char *fmt; | |||
@@ -312,14 +254,8 @@ bool img_load(img_t *img, const fileinfo_t *file) { | |||
warn("could not open image: %s", file->name); | |||
return false; | |||
} | |||
#if EXIF_SUPPORT | |||
if (STREQ(fmt, "jpeg")) | |||
exif_auto_orientate(file); | |||
#endif | |||
#if GIF_SUPPORT | |||
if (STREQ(fmt, "gif")) | |||
img_load_gif(img, file); | |||
#endif | |||
img->w = imlib_image_get_width(); | |||
img->h = imlib_image_get_height(); | |||
@@ -17,7 +17,6 @@ | |||
*/ | |||
#define _POSIX_C_SOURCE 200112L | |||
#define _FEATURE_CONFIG | |||
#define _IMAGE_CONFIG | |||
#include <stdlib.h> | |||
@@ -39,18 +38,6 @@ void print_usage(void) { | |||
void print_version(void) { | |||
printf("sxiv %s - Simple X Image Viewer\n", VERSION); | |||
printf("Additional features included (+) or not (-): %s, %s\n", | |||
#if EXIF_SUPPORT | |||
"+exif", | |||
#else | |||
"-exif", | |||
#endif | |||
#if GIF_SUPPORT | |||
"+gif" | |||
#else | |||
"-gif" | |||
#endif | |||
); | |||
} | |||
void parse_options(int argc, char **argv) { | |||
@@ -17,7 +17,6 @@ | |||
*/ | |||
#define _POSIX_C_SOURCE 200112L | |||
#define _FEATURE_CONFIG | |||
#define _THUMBS_CONFIG | |||
#include <stdlib.h> | |||
@@ -31,10 +30,6 @@ | |||
#include "util.h" | |||
#include "config.h" | |||
#if EXIF_SUPPORT | |||
void exif_auto_orientate(const fileinfo_t*); | |||
#endif | |||
const int thumb_dim = THUMB_SIZE + 10; | |||
char *cache_dir = NULL; | |||
@@ -211,7 +206,7 @@ void tns_free(tns_t *tns) { | |||
} | |||
bool tns_load(tns_t *tns, int n, const fileinfo_t *file, | |||
bool force, bool silent) | |||
bool force, bool silent) | |||
{ | |||
int w, h; | |||
bool use_cache, cache_hit = false; | |||
@@ -259,10 +254,6 @@ bool tns_load(tns_t *tns, int n, const fileinfo_t *file, | |||
imlib_free_image_and_decache(); | |||
return false; | |||
} | |||
#if EXIF_SUPPORT | |||
if (!cache_hit && STREQ(fmt, "jpeg")) | |||
exif_auto_orientate(file); | |||
#endif | |||
w = imlib_image_get_width(); | |||
h = imlib_image_get_height(); | |||