summaryrefslogtreecommitdiffstats
path: root/mpd-notification.c
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2016-10-05 15:56:28 +0200
committerGravatar Christian Hesse <mail@eworm.de>2016-10-05 22:40:32 +0200
commit81300293395926cf1b7633db4679f3e5ab6beca0 (patch)
treed211903d36f20861a4f841e1c5c6264ae7c652a5 /mpd-notification.c
parent9fea2b316110f47a0e561bb1ba498e9d5c9e43a3 (diff)
downloadmpd-notification-81300293395926cf1b7633db4679f3e5ab6beca0.tar.gz
mpd-notification-81300293395926cf1b7633db4679f3e5ab6beca0.tar.zst
keep aspect ratio when scaling
Diffstat (limited to 'mpd-notification.c')
-rw-r--r--mpd-notification.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/mpd-notification.c b/mpd-notification.c
index c271131..8713947 100644
--- a/mpd-notification.c
+++ b/mpd-notification.c
@@ -345,7 +345,15 @@ int main(int argc, char ** argv) {
printf("%s: found artwork in or near media file: %s/%s\n", program, music_dir, uri);
if (scale > 0) {
- if ((copy = gdk_pixbuf_scale_simple (pixbuf, scale, scale, GDK_INTERP_BILINEAR)) != NULL) {
+ int x, y;
+
+ x = gdk_pixbuf_get_width(pixbuf);
+ y = gdk_pixbuf_get_height(pixbuf);
+
+ if ((copy = gdk_pixbuf_scale_simple (pixbuf,
+ (x > y ? scale : scale * x / y),
+ (y > x ? scale : scale * y / x),
+ GDK_INTERP_BILINEAR)) != NULL) {
g_object_unref(pixbuf);
pixbuf = copy;
}