* lisp/image-mode.el (image-toggle-display-image): Fix fit of rotated images.
When fitting rotated image to width and height, swap width and height when changing orientation between portrait and landscape (bug#41886).
This commit is contained in:
parent
a71d1787f1
commit
1dff0a8949
1 changed files with 12 additions and 4 deletions
|
@ -810,8 +810,12 @@ was inserted."
|
||||||
filename))
|
filename))
|
||||||
;; If we have a `fit-width' or a `fit-height', don't limit
|
;; If we have a `fit-width' or a `fit-height', don't limit
|
||||||
;; the size of the image to the window size.
|
;; the size of the image to the window size.
|
||||||
(edges (and (eq image-transform-resize t)
|
(edges (when (eq image-transform-resize t)
|
||||||
(window-inside-pixel-edges (get-buffer-window))))
|
(window-inside-pixel-edges (get-buffer-window))))
|
||||||
|
(max-width (when edges
|
||||||
|
(- (nth 2 edges) (nth 0 edges))))
|
||||||
|
(max-height (when edges
|
||||||
|
(- (nth 3 edges) (nth 1 edges))))
|
||||||
(type (if (image--imagemagick-wanted-p filename)
|
(type (if (image--imagemagick-wanted-p filename)
|
||||||
'imagemagick
|
'imagemagick
|
||||||
(image-type file-or-data nil data-p)))
|
(image-type file-or-data nil data-p)))
|
||||||
|
@ -827,14 +831,18 @@ was inserted."
|
||||||
(ignore-error exif-error
|
(ignore-error exif-error
|
||||||
(exif-parse-buffer)))
|
(exif-parse-buffer)))
|
||||||
0.0)))
|
0.0)))
|
||||||
|
;; Swap width and height when changing orientation
|
||||||
|
;; between portrait and landscape.
|
||||||
|
(when (and edges (zerop (mod (+ image-transform-rotation 90) 180)))
|
||||||
|
(setq max-width (prog1 max-height (setq max-height max-width))))
|
||||||
|
|
||||||
;; :scale 1: If we do not set this, create-image will apply
|
;; :scale 1: If we do not set this, create-image will apply
|
||||||
;; default scaling based on font size.
|
;; default scaling based on font size.
|
||||||
(setq image (if (not edges)
|
(setq image (if (not edges)
|
||||||
(create-image file-or-data type data-p :scale 1)
|
(create-image file-or-data type data-p :scale 1)
|
||||||
(create-image file-or-data type data-p :scale 1
|
(create-image file-or-data type data-p :scale 1
|
||||||
:max-width (- (nth 2 edges) (nth 0 edges))
|
:max-width max-width
|
||||||
:max-height (- (nth 3 edges) (nth 1 edges)))))
|
:max-height max-height)))
|
||||||
|
|
||||||
;; Discard any stale image data before looking it up again.
|
;; Discard any stale image data before looking it up again.
|
||||||
(image-flush image)
|
(image-flush image)
|
||||||
|
|
Loading…
Add table
Reference in a new issue