diff options
author | Lars Magne Ingebrigtsen <larsi@gnus.org> | 2014-09-18 20:34:59 +0200 |
---|---|---|
committer | Lars Magne Ingebrigtsen <larsi@gnus.org> | 2014-09-18 20:34:59 +0200 |
commit | 999c35f47271f099e178ad2e2ea015509acbe633 (patch) | |
tree | 14d52e35d584c3f434015efb2fca363e68193282 /lisp/image-mode.el | |
parent | 3cab7dd46f43dfb3131a08d7d9fc5c05f221c454 (diff) | |
download | emacs-999c35f47271f099e178ad2e2ea015509acbe633.tar.gz emacs-999c35f47271f099e178ad2e2ea015509acbe633.tar.bz2 emacs-999c35f47271f099e178ad2e2ea015509acbe633.zip |
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.
Diffstat (limited to 'lisp/image-mode.el')
-rw-r--r-- | lisp/image-mode.el | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lisp/image-mode.el b/lisp/image-mode.el index 492ac10d706..ee5a1e7906e 100644 --- a/lisp/image-mode.el +++ b/lisp/image-mode.el @@ -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)) |