summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md3
-rw-r--r--mpd-notification.c10
2 files changed, 11 insertions, 2 deletions
diff --git a/README.md b/README.md
index dd876ec..f834801 100644
--- a/README.md
+++ b/README.md
@@ -61,8 +61,9 @@ or `systemctl --user enable mpd-notification`.
* *-m MUSIC-DIR*: use *MUSIC-DIR* for artwork lookup
* *-o*: Notification text is one line (no line breaks)
* *-p PORT*: connect to *PORT*
+* *-s PIXELS*: scale image to a maximum size *PIXELS* x *PIXELS* pixels, keeping
+ ratio
* *-t TIMEOUT*: notification timeout, *TIMEOUT* in seconds
-* *-s PIXELS*: scale image to *PIXELS* x *PIXELS* pixels
* *-v*: verbose output
* *-V*: print version information
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;
}