1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-02-17 21:51:00 -08:00

Make image scaling work without imagemagick support in eww

* lisp/net/shr.el (shr-rescale-image): Emacs has native image
scaling now, so images can be rescaled without imagemagick
support.
This commit is contained in:
Lars Ingebrigtsen 2019-05-15 02:53:56 +02:00
parent 4b2c9f638a
commit e3fbe04cbc

View file

@ -1101,39 +1101,36 @@ WIDTH and HEIGHT are the sizes given in the HTML data, if any.
The size of the displayed image will not exceed
MAX-WIDTH/MAX-HEIGHT. If not given, use the current window
width/height instead."
(if (or (not (fboundp 'imagemagick-types))
(not (get-buffer-window (current-buffer))))
(create-image data nil t :ascent 100)
(let* ((edges (window-inside-pixel-edges
(get-buffer-window (current-buffer))))
(max-width (truncate (* shr-max-image-proportion
(or max-width
(- (nth 2 edges) (nth 0 edges))))))
(max-height (truncate (* shr-max-image-proportion
(or max-height
(- (nth 3 edges) (nth 1 edges))))))
(scaling (image-compute-scaling-factor image-scaling-factor)))
(when (or (and width
(> width max-width))
(and height
(> height max-height)))
(setq width nil
height nil))
(if (and width height
(< (* width scaling) max-width)
(< (* height scaling) max-height))
(create-image
data 'imagemagick t
:ascent 100
:width width
:height height
:format content-type)
(let* ((edges (window-inside-pixel-edges
(get-buffer-window (current-buffer))))
(max-width (truncate (* shr-max-image-proportion
(or max-width
(- (nth 2 edges) (nth 0 edges))))))
(max-height (truncate (* shr-max-image-proportion
(or max-height
(- (nth 3 edges) (nth 1 edges))))))
(scaling (image-compute-scaling-factor image-scaling-factor)))
(when (or (and width
(> width max-width))
(and height
(> height max-height)))
(setq width nil
height nil))
(if (and width height
(< (* width scaling) max-width)
(< (* height scaling) max-height))
(create-image
data 'imagemagick t
data nil t
:ascent 100
:max-width max-width
:max-height max-height
:format content-type)))))
:width width
:height height
:format content-type)
(create-image
data nil t
:ascent 100
:max-width max-width
:max-height max-height
:format content-type))))
;; url-cache-extract autoloads url-cache.
(declare-function url-cache-create-filename "url-cache" (url))