From 524a8eb7307b3efc1124c35014b46ecb2f99818f Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Wed, 25 Sep 2019 14:47:52 +0200 Subject: [PATCH] Make gnus-rescale-image work on modern Emacs versions * lisp/gnus/gnus-util.el (gnus-rescale-image): Make this work with native image transforms. --- lisp/gnus/gnus-util.el | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/lisp/gnus/gnus-util.el b/lisp/gnus/gnus-util.el index 6847d372cc5..dc779d04874 100644 --- a/lisp/gnus/gnus-util.el +++ b/lisp/gnus/gnus-util.el @@ -1606,26 +1606,19 @@ empty directories from OLD-PATH." (ignore-errors (set-file-modes filename mode))) -(declare-function image-size "image.c" (spec &optional pixels frame)) - (defun gnus-rescale-image (image size) "Rescale IMAGE to SIZE if possible. SIZE is in format (WIDTH . HEIGHT). Return a new image. Sizes are in pixels." - (if (not (fboundp 'imagemagick-types)) - image - (let ((new-width (car size)) - (new-height (cdr size))) - (when (> (cdr (image-size image t)) new-height) - (setq image (or (create-image (plist-get (cdr image) :data) 'imagemagick t - :height new-height) - image))) - (when (> (car (image-size image t)) new-width) - (setq image (or - (create-image (plist-get (cdr image) :data) 'imagemagick t - :width new-width) - image))) - image))) + (let ((new-width (car size)) + (new-height (cdr size))) + (when (> (cdr (image-size image t)) new-height) + (setq image (create-image (plist-get (cdr image) :data) nil t + :max-height new-height))) + (when (> (car (image-size image t)) new-width) + (setq image (create-image (plist-get (cdr image) :data) nil t + :max-width new-width))) + image)) (defun gnus-recursive-directory-files (dir) "Return all regular files below DIR. -- 2.39.2