diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2019-06-12 19:00:37 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2019-06-12 19:00:43 +0200 |
commit | 2d71e68428b10c593da2dd411d70ed2b4a8632c0 (patch) | |
tree | 665a84ebab0d5a837fcd3399ebf32af2297052ed /lisp/net | |
parent | 26f2b1faaa1dc8847f2013268c20f51c144ae711 (diff) | |
download | emacs-2d71e68428b10c593da2dd411d70ed2b4a8632c0.tar.gz emacs-2d71e68428b10c593da2dd411d70ed2b4a8632c0.tar.bz2 emacs-2d71e68428b10c593da2dd411d70ed2b4a8632c0.zip |
Restore image scaling support when there's no native image scaling
* lisp/net/shr.el (shr--image-type): New function.
(shr-rescale-image): Use it to allow image scaling on Emacsen with
ImageMagick support that does not have native image scaling support.
Diffstat (limited to 'lisp/net')
-rw-r--r-- | lisp/net/shr.el | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lisp/net/shr.el b/lisp/net/shr.el index c1e9fdd30d7..a014c56948c 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -1093,6 +1093,16 @@ element is the data blob and the second element is the content-type." image) (insert (or alt "")))) +(defun shr--image-type () + "Emacs image type to use when displaying images. +If Emacs has native image scaling support, that's used, but if +not, `imagemagick' is preferred if it's present." + (if (or (and (fboundp 'image-transforms-p) + (image-transforms-p)) + (not (fboundp 'imagemagick-types))) + nil + 'imagemagick)) + (defun shr-rescale-image (data content-type width height &optional max-width max-height) "Rescale DATA, if too big, to fit the current buffer. @@ -1122,13 +1132,13 @@ width/height instead." (< (* width scaling) max-width) (< (* height scaling) max-height)) (create-image - data nil t + data (shr--image-type) t :ascent 100 :width width :height height :format content-type) (create-image - data nil t + data (shr--image-type) t :ascent 100 :max-width max-width :max-height max-height |