]> git.eshelyaron.com Git - emacs.git/commitdiff
Preserve the aspect ratio when fitting to width/height
authorLars Magne Ingebrigtsen <larsi@gnus.org>
Thu, 18 Sep 2014 18:34:59 +0000 (20:34 +0200)
committerLars Magne Ingebrigtsen <larsi@gnus.org>
Thu, 18 Sep 2014 18:34:59 +0000 (20:34 +0200)
* 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.

lisp/ChangeLog
lisp/image-mode.el

index caeda7ae3e368756d3eaa73ffda1ab4a9214914d..0a92a7ed4b94954d563c406b6cbb9ba6600c6c0f 100644 (file)
@@ -1,3 +1,10 @@
+2014-09-18  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+       * 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.
+
 2014-09-17  Reuben Thomas  <rrt@sc3d.org>
 
        * progmodes/js.el: Add interpreter-mode-alist support for various
index 492ac10d706c2f3dd529fb3eb2b2a444ee3af212..ee5a1e7906e7b215276a8a0665e797b04785429f 100644 (file)
@@ -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))