mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
Preserve the aspect ratio when fitting to width/height
* image-mode.el (image-toggle-display-image): If we have a `fit-width' or a `fit-height', don't limit the size of the image to the window size, because that doesn't preserve the aspect ratio.
This commit is contained in:
parent
3cab7dd46f
commit
999c35f472
2 changed files with 17 additions and 5 deletions
|
|
@ -642,14 +642,19 @@ was inserted."
|
|||
(string-make-unibyte
|
||||
(buffer-substring-no-properties (point-min) (point-max)))
|
||||
filename))
|
||||
(edges (window-inside-pixel-edges
|
||||
(get-buffer-window (current-buffer))))
|
||||
;; If we have a `fit-width' or a `fit-height', don't limit
|
||||
;; the size of the image to the window size.
|
||||
(edges (and (null image-transform-resize)
|
||||
(window-inside-pixel-edges
|
||||
(get-buffer-window (current-buffer)))))
|
||||
(type (if (fboundp 'imagemagick-types)
|
||||
'imagemagick
|
||||
(image-type file-or-data nil data-p)))
|
||||
(image (create-image file-or-data type data-p
|
||||
:max-width (- (nth 2 edges) (nth 0 edges))
|
||||
:max-height (- (nth 3 edges) (nth 1 edges))))
|
||||
(image (if (not edges)
|
||||
(create-image file-or-data type data-p)
|
||||
(create-image file-or-data type data-p
|
||||
:max-width (- (nth 2 edges) (nth 0 edges))
|
||||
:max-height (- (nth 3 edges) (nth 1 edges)))))
|
||||
(inhibit-read-only t)
|
||||
(buffer-undo-list t)
|
||||
(modified (buffer-modified-p))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue