From 426edfb3498469b171aae6a582491c2c7e30fd51 Mon Sep 17 00:00:00 2001 From: Bert Date: Tue, 5 Apr 2011 00:37:37 +0200 Subject: Readded file-type check at startup --- image.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'image.c') diff --git a/image.c b/image.c index 02df898..a7530a8 100644 --- a/image.c +++ b/image.c @@ -56,6 +56,23 @@ void img_free(img_t* img) { imlib_free_image(); } +int img_check(const char *filename) { + Imlib_Image *im; + + if (!filename) + return 0; + + if ((im = imlib_load_image(filename))) { + imlib_context_set_image(im); + imlib_image_set_changes_on_disk(); + imlib_free_image(); + return 1; + } else { + warn("invalid file: %s", filename); + return 0; + } +} + int img_load(img_t *img, const char *filename) { if (!img || !filename) return 0; @@ -66,7 +83,7 @@ int img_load(img_t *img, const char *filename) { imlib_context_set_anti_alias(img->aa); img->scalemode = options->scalemode; } else { - warn("not an image: %s", filename); + warn("invalid file: %s", filename); imlib_context_set_image(im_invalid); imlib_context_set_anti_alias(0); } -- cgit v1.2.3-54-g00ecf