nsxivd8114e8
Thumbnail cache file format depending on existance of alpha layer
Use PNG if image has alpha layer, JPG if not. Fixes issue #209
+9 −5
2 files changed
| @@ -1,4 +1,4 @@ | |||
| 1 | − | VERSION := git-20150518 | |
| 1 | + | VERSION := git-20150722 | |
| 2 | 2 | ||
| 3 | 3 | PREFIX := /usr/local | |
| 4 | 4 | MANPREFIX := $(PREFIX)/share/man | |
| @@ -48,9 +48,9 @@ char* tns_cache_filepath(const char *filepath) | |||
| 48 | 48 | ||
| 49 | 49 | if (strncmp(filepath, cache_dir, strlen(cache_dir)) != 0) { | |
| 50 | 50 | /* don't cache images inside the cache directory! */ | |
| 51 | − | len = strlen(cache_dir) + strlen(filepath) + 6; | |
| 51 | + | len = strlen(cache_dir) + strlen(filepath) + 2; | |
| 52 | 52 | cfile = (char*) s_malloc(len); | |
| 53 | − | snprintf(cfile, len, "%s/%s.jpg", cache_dir, filepath + 1); | |
| 53 | + | snprintf(cfile, len, "%s/%s", cache_dir, filepath + 1); | |
| 54 | 54 | } | |
| 55 | 55 | return cfile; | |
| 56 | 56 | } | |
| @@ -101,8 +101,12 @@ void tns_cache_write(Imlib_Image im, const char *filepath, bool force) | |||
| 101 | 101 | } | |
| 102 | 102 | if (err == 0) { | |
| 103 | 103 | imlib_context_set_image(im); | |
| 104 | − | imlib_image_set_format("jpg"); | |
| 105 | − | imlib_image_attach_data_value("quality", NULL, 90, NULL); | |
| 104 | + | if (imlib_image_has_alpha()) { | |
| 105 | + | imlib_image_set_format("png"); | |
| 106 | + | } else { | |
| 107 | + | imlib_image_set_format("jpg"); | |
| 108 | + | imlib_image_attach_data_value("quality", NULL, 90, NULL); | |
| 109 | + | } | |
| 106 | 110 | imlib_save_image_with_error_return(cfile, &err); | |
| 107 | 111 | } | |
| 108 | 112 | if (err == 0) { | |