aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Magne Ingebrigtsen2014-09-18 20:34:59 +0200
committerLars Magne Ingebrigtsen2014-09-18 20:34:59 +0200
commit999c35f47271f099e178ad2e2ea015509acbe633 (patch)
tree14d52e35d584c3f434015efb2fca363e68193282
parent3cab7dd46f43dfb3131a08d7d9fc5c05f221c454 (diff)
downloademacs-999c35f47271f099e178ad2e2ea015509acbe633.tar.gz
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.
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/image-mode.el15
2 files changed, 17 insertions, 5 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index caeda7ae3e3..0a92a7ed4b9 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
12014-09-18 Lars Magne Ingebrigtsen <larsi@gnus.org>
2
3 * image-mode.el (image-toggle-display-image): If we have a
4 `fit-width' or a `fit-height', don't limit the size of the image
5 to the window size, because that doesn't preserve the aspect
6 ratio.
7
12014-09-17 Reuben Thomas <rrt@sc3d.org> 82014-09-17 Reuben Thomas <rrt@sc3d.org>
2 9
3 * progmodes/js.el: Add interpreter-mode-alist support for various 10 * progmodes/js.el: Add interpreter-mode-alist support for various
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."
642 (string-make-unibyte 642 (string-make-unibyte
643 (buffer-substring-no-properties (point-min) (point-max))) 643 (buffer-substring-no-properties (point-min) (point-max)))
644 filename)) 644 filename))
645 (edges (window-inside-pixel-edges 645 ;; If we have a `fit-width' or a `fit-height', don't limit
646 (get-buffer-window (current-buffer)))) 646 ;; the size of the image to the window size.
647 (edges (and (null image-transform-resize)
648 (window-inside-pixel-edges
649 (get-buffer-window (current-buffer)))))
647 (type (if (fboundp 'imagemagick-types) 650 (type (if (fboundp 'imagemagick-types)
648 'imagemagick 651 'imagemagick
649 (image-type file-or-data nil data-p))) 652 (image-type file-or-data nil data-p)))
650 (image (create-image file-or-data type data-p 653 (image (if (not edges)
651 :max-width (- (nth 2 edges) (nth 0 edges)) 654 (create-image file-or-data type data-p)
652 :max-height (- (nth 3 edges) (nth 1 edges)))) 655 (create-image file-or-data type data-p
656 :max-width (- (nth 2 edges) (nth 0 edges))
657 :max-height (- (nth 3 edges) (nth 1 edges)))))
653 (inhibit-read-only t) 658 (inhibit-read-only t)
654 (buffer-undo-list t) 659 (buffer-undo-list t)
655 (modified (buffer-modified-p)) 660 (modified (buffer-modified-p))