From: Lars Magne Ingebrigtsen Date: Tue, 5 Aug 2014 18:18:39 +0000 (+0200) Subject: Use a max-width when displaying images X-Git-Tag: emacs-25.0.90~2635^2~679^2~520 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=81d0eae7142f85f25dc816fe283625a6567d349c;p=emacs.git Use a max-width when displaying images * lisp/image-mode.el (image-toggle-display-image): Alway rescale images to not be bigger than the current window. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index adca3166187..53a20d50250 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2014-08-05 Lars Magne Ingebrigtsen + + * image-mode.el (image-toggle-display-image): Alway rescale images + to not be bigger than the current window. + 2014-08-05 Eric Brown (tiny change) * net/eww.el (eww-bookmarks-directory): New variable. diff --git a/lisp/image-mode.el b/lisp/image-mode.el index b75946475dd..76a64220413 100644 --- a/lisp/image-mode.el +++ b/lisp/image-mode.el @@ -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))