[rhythmbox] shell: reject images that are fewer than 32 pixels wide or high
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox] shell: reject images that are fewer than 32 pixels wide or high
- Date: Sun, 22 Mar 2015 04:26:42 +0000 (UTC)
commit 4516f5e2d37c40f70c42f65232a79142fb354357
Author: Jonathan Matthew <jonathan d14n org>
Date: Sun Mar 22 14:07:00 2015 +1000
shell: reject images that are fewer than 32 pixels wide or high
Amazon gives us 1x1 gifs sometimes, which aren't very useful as
album art.
shell/rb-shell.c | 24 ++++++++++++++++++++++++
1 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/shell/rb-shell.c b/shell/rb-shell.c
index 4cd6304..be50082 100644
--- a/shell/rb-shell.c
+++ b/shell/rb-shell.c
@@ -107,6 +107,8 @@
#define PLAYING_ENTRY_NOTIFY_TIME 4
+#define ALBUM_ART_MIN_SIZE 32
+
static void rb_shell_class_init (RBShellClass *klass);
static void rb_shell_init (RBShell *shell);
static void rb_shell_constructed (GObject *object);
@@ -316,6 +318,19 @@ rb_shell_create_mount_op_cb (RhythmDB *db, RBShell *shell)
return op;
}
+static gboolean
+accept_art_pixbuf (GdkPixbuf *pixbuf)
+{
+ if ((gdk_pixbuf_get_width (pixbuf) < ALBUM_ART_MIN_SIZE) ||
+ (gdk_pixbuf_get_height (pixbuf) < ALBUM_ART_MIN_SIZE)) {
+ rb_debug ("rejecting too small (%dx%d) image",
+ gdk_pixbuf_get_width (pixbuf),
+ gdk_pixbuf_get_height (pixbuf));
+ return FALSE;
+ }
+ return TRUE;
+}
+
static GValue *
load_external_art_cb (RBExtDB *store, GValue *value, RBShell *shell)
{
@@ -360,6 +375,12 @@ load_external_art_cb (RBExtDB *store, GValue *value, RBShell *shell)
}
pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
+ if (accept_art_pixbuf (pixbuf) == FALSE) {
+ g_object_unref (pixbuf);
+ g_object_unref (loader);
+ return NULL;
+ }
+
v = g_new0 (GValue, 1);
g_value_init (v, GDK_TYPE_PIXBUF);
g_value_set_object (v, pixbuf);
@@ -393,6 +414,9 @@ store_external_art_cb (RBExtDB *store, GValue *value, RBShell *shell)
}
pixbuf = GDK_PIXBUF (g_value_get_object (value));
+ if (accept_art_pixbuf (pixbuf) == FALSE) {
+ return NULL;
+ }
/* switch to png if the image has an alpha channel */
if (gdk_pixbuf_get_has_alpha (pixbuf)) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]