From 81300293395926cf1b7633db4679f3e5ab6beca0 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 5 Oct 2016 15:56:28 +0200 Subject: keep aspect ratio when scaling --- mpd-notification.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'mpd-notification.c') 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; } -- cgit v1.2.3-54-g00ecf