summaryrefslogtreecommitdiff
path: root/libappstream-glib/as-image.c
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2016-01-22 16:18:08 +0000
committerRichard Hughes <richard@hughsie.com>2016-01-22 17:11:30 +0000
commit7972026fda210e8d8001df7ad2b11b8cb3bcd8b5 (patch)
treeb8523d41a46a48ae0873e1f0ab8bbe9bbbe6f1ba /libappstream-glib/as-image.c
parentd12d2cffe4d8ae10d84aa57bb21927256040894b (diff)
downloadappstream-glib-7972026fda210e8d8001df7ad2b11b8cb3bcd8b5.tar.gz
Only load supported icon kinds when using appstream-compose
Diffstat (limited to 'libappstream-glib/as-image.c')
-rw-r--r--libappstream-glib/as-image.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/libappstream-glib/as-image.c b/libappstream-glib/as-image.c
index 10e1032..49a86c2 100644
--- a/libappstream-glib/as-image.c
+++ b/libappstream-glib/as-image.c
@@ -503,6 +503,29 @@ as_image_load_filename_full (AsImage *image,
g_autoptr(GdkPixbuf) pixbuf_src = NULL;
g_autoptr(GdkPixbuf) pixbuf_tmp = NULL;
+ /* only support non-deprecated types */
+ if (flags & AS_IMAGE_LOAD_FLAG_ONLY_SUPPORTED) {
+ GdkPixbufFormat *fmt;
+ fmt = gdk_pixbuf_get_file_info (filename, NULL, NULL);
+ if (fmt == NULL) {
+ g_set_error_literal (error,
+ AS_UTILS_ERROR,
+ AS_UTILS_ERROR_FAILED,
+ "image format was not recognized");
+ return FALSE;
+ }
+ if (g_strcmp0 (gdk_pixbuf_format_get_name (fmt), "png") != 0 &&
+ g_strcmp0 (gdk_pixbuf_format_get_name (fmt), "jpeg") != 0 &&
+ g_strcmp0 (gdk_pixbuf_format_get_name (fmt), "svg") != 0) {
+ g_set_error (error,
+ AS_UTILS_ERROR,
+ AS_UTILS_ERROR_FAILED,
+ "image format %s is not supported",
+ gdk_pixbuf_format_get_name (fmt));
+ return FALSE;
+ }
+ }
+
/* update basename */
if (flags & AS_IMAGE_LOAD_FLAG_SET_BASENAME) {
g_autofree gchar *basename = NULL;