Commit e3fbe04c authored by Lars Ingebrigtsen's avatar Lars Ingebrigtsen

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.
parent 4b2c9f63
Pipeline #1664 passed with stage
in 51 minutes and 13 seconds
...@@ -1101,39 +1101,36 @@ WIDTH and HEIGHT are the sizes given in the HTML data, if any. ...@@ -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 The size of the displayed image will not exceed
MAX-WIDTH/MAX-HEIGHT. If not given, use the current window MAX-WIDTH/MAX-HEIGHT. If not given, use the current window
width/height instead." width/height instead."
(if (or (not (fboundp 'imagemagick-types)) (let* ((edges (window-inside-pixel-edges
(not (get-buffer-window (current-buffer)))) (get-buffer-window (current-buffer))))
(create-image data nil t :ascent 100) (max-width (truncate (* shr-max-image-proportion
(let* ((edges (window-inside-pixel-edges (or max-width
(get-buffer-window (current-buffer)))) (- (nth 2 edges) (nth 0 edges))))))
(max-width (truncate (* shr-max-image-proportion (max-height (truncate (* shr-max-image-proportion
(or max-width (or max-height
(- (nth 2 edges) (nth 0 edges)))))) (- (nth 3 edges) (nth 1 edges))))))
(max-height (truncate (* shr-max-image-proportion (scaling (image-compute-scaling-factor image-scaling-factor)))
(or max-height (when (or (and width
(- (nth 3 edges) (nth 1 edges)))))) (> width max-width))
(scaling (image-compute-scaling-factor image-scaling-factor))) (and height
(when (or (and width (> height max-height)))
(> width max-width)) (setq width nil
(and height height nil))
(> height max-height))) (if (and width height
(setq width nil (< (* width scaling) max-width)
height nil)) (< (* height scaling) max-height))
(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)
(create-image (create-image
data 'imagemagick t data nil t
:ascent 100 :ascent 100
:max-width max-width :width width
:max-height max-height :height height
:format content-type))))) :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. ;; url-cache-extract autoloads url-cache.
(declare-function url-cache-create-filename "url-cache" (url)) (declare-function url-cache-create-filename "url-cache" (url))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment