]> git.eshelyaron.com Git - emacs.git/commitdiff
Use a max-width when displaying images
authorLars Magne Ingebrigtsen <larsi@gnus.org>
Tue, 5 Aug 2014 18:18:39 +0000 (20:18 +0200)
committerLars Magne Ingebrigtsen <larsi@gnus.org>
Tue, 5 Aug 2014 18:18:39 +0000 (20:18 +0200)
* lisp/image-mode.el (image-toggle-display-image): Alway rescale images
to not be bigger than the current window.

lisp/ChangeLog
lisp/image-mode.el

index adca31661872531aaf5b630208ebe1b3687e42bf..53a20d50250536050e1079c2165e056cfc3ce964 100644 (file)
@@ -1,3 +1,8 @@
+2014-08-05  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+       * image-mode.el (image-toggle-display-image): Alway rescale images
+       to not be bigger than the current window.
+
 2014-08-05  Eric Brown  <brown@fastmail.fm>  (tiny change)
 
        * net/eww.el (eww-bookmarks-directory): New variable.
index b75946475dd652fad21168a40893cf4912f8514b..76a64220413692abf43cbddb9c799a68e9d8f28f 100644 (file)
@@ -638,8 +638,14 @@ was inserted."
                           (string-make-unibyte
                            (buffer-substring-no-properties (point-min) (point-max)))
                         filename))
-        (type (image-type file-or-data nil data-p))
-        (image (create-image file-or-data type data-p))
+        (edges (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))))
         (inhibit-read-only t)
         (buffer-undo-list t)
         (modified (buffer-modified-p))