aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBert Münnich <ber.t@posteo.de>2015-07-22 21:08:00 +0200
committerBert Münnich <ber.t@posteo.de>2015-07-22 21:08:00 +0200
commitd8114e841c5b5933a655a3ec728cedd37b86d27d (patch)
tree2be7e565f37243daac529efc037d50c17e1d5e08
parent9264a65c192c9678fa4a048fdbb177ebf487c6b9 (diff)
Thumbnail cache file format depending on existance of alpha layer
Use PNG if image has alpha layer, JPG if not. Fixes issue #209
-rw-r--r--Makefile2
-rw-r--r--thumbs.c12
2 files changed, 9 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 003758b..8957a46 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-VERSION := git-20150518
+VERSION := git-20150722
PREFIX := /usr/local
MANPREFIX := $(PREFIX)/share/man
diff --git a/thumbs.c b/thumbs.c
index 209c94b..3c18c27 100644
--- a/thumbs.c
+++ b/thumbs.c
@@ -48,9 +48,9 @@ char* tns_cache_filepath(const char *filepath)
if (strncmp(filepath, cache_dir, strlen(cache_dir)) != 0) {
/* don't cache images inside the cache directory! */
- len = strlen(cache_dir) + strlen(filepath) + 6;
+ len = strlen(cache_dir) + strlen(filepath) + 2;
cfile = (char*) s_malloc(len);
- snprintf(cfile, len, "%s/%s.jpg", cache_dir, filepath + 1);
+ snprintf(cfile, len, "%s/%s", cache_dir, filepath + 1);
}
return cfile;
}
@@ -101,8 +101,12 @@ void tns_cache_write(Imlib_Image im, const char *filepath, bool force)
}
if (err == 0) {
imlib_context_set_image(im);
- imlib_image_set_format("jpg");
- imlib_image_attach_data_value("quality", NULL, 90, NULL);
+ if (imlib_image_has_alpha()) {
+ imlib_image_set_format("png");
+ } else {
+ imlib_image_set_format("jpg");
+ imlib_image_attach_data_value("quality", NULL, 90, NULL);
+ }
imlib_save_image_with_error_return(cfile, &err);
}
if (err == 0) {