summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2019-09-25 14:47:52 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2019-09-25 14:47:52 +0200
commit524a8eb7307b3efc1124c35014b46ecb2f99818f (patch)
treec1b05b526d5495c74ca555a5b27f8d6c8ed00638
parent165890a70a256ce5c5f5953ac35239c295234684 (diff)
downloademacs-524a8eb7307b3efc1124c35014b46ecb2f99818f.tar.gz
Make gnus-rescale-image work on modern Emacs versions
* lisp/gnus/gnus-util.el (gnus-rescale-image): Make this work with native image transforms.
-rw-r--r--lisp/gnus/gnus-util.el25
1 files 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.