aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/gnus/ChangeLog3
-rw-r--r--lisp/gnus/gnus-html.el32
2 files changed, 34 insertions, 1 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 884441db4b8..711e7194d39 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -7,6 +7,9 @@
72010-09-01 Lars Magne Ingebrigtsen <larsi@gnus.org> 72010-09-01 Lars Magne Ingebrigtsen <larsi@gnus.org>
8 8
9 * gnus-html.el (gnus-html-wash-tags): Delete the IMG_ALT region. 9 * gnus-html.el (gnus-html-wash-tags): Delete the IMG_ALT region.
10 (gnus-max-image-proportion): New variable.
11 (gnus-html-rescale-image): New function.
12 (gnus-html-put-image): Rescale images.
10 13
112010-09-01 Stefan Monnier <monnier@iro.umontreal.ca> 142010-09-01 Stefan Monnier <monnier@iro.umontreal.ca>
12 15
diff --git a/lisp/gnus/gnus-html.el b/lisp/gnus/gnus-html.el
index 2e44c3f5607..a89a3f57ff1 100644
--- a/lisp/gnus/gnus-html.el
+++ b/lisp/gnus/gnus-html.el
@@ -56,6 +56,16 @@
56 :group 'gnus-art 56 :group 'gnus-art
57 :type 'regexp) 57 :type 'regexp)
58 58
59(defcustom gnus-max-image-proportion 0.7
60 "How big pictures displayed are in relation to the window they're in.
61A value of 0.7 means that they are allowed to take up 70% of the
62width and height of the window. If they are larger than this,
63and Emacs supports it, then the images will be rescaled down to
64fit these criteria."
65 :version "24.1"
66 :group 'gnus-art
67 :type 'float)
68
59;;;###autoload 69;;;###autoload
60(defun gnus-article-html (handle) 70(defun gnus-article-html (handle)
61 (let ((article-buffer (current-buffer))) 71 (let ((article-buffer (current-buffer)))
@@ -219,13 +229,33 @@
219 (= (car (image-size image t)) 30) 229 (= (car (image-size image t)) 30)
220 (= (cdr (image-size image t)) 30)))) 230 (= (cdr (image-size image t)) 30))))
221 (progn 231 (progn
222 (gnus-put-image image) 232 (gnus-put-image (gnus-html-rescale-image image))
223 t) 233 t)
224 (when (fboundp 'find-image) 234 (when (fboundp 'find-image)
225 (gnus-put-image (find-image 235 (gnus-put-image (find-image
226 '((:type xpm :file "lock-broken.xpm"))))) 236 '((:type xpm :file "lock-broken.xpm")))))
227 nil))))) 237 nil)))))
228 238
239(defun gnus-html-rescale-image (image)
240 (if (not (fboundp 'imagemagick-types))
241 image
242 (let* ((width (car (image-size image t)))
243 (height (cdr (image-size image t)))
244 (edges (window-pixel-edges))
245 (window-width (truncate (* gnus-max-image-proportion
246 (- (nth 2 edges) (nth 0 edges)))))
247 (window-height (truncate (* gnus-max-image-proportion
248 (- (nth 3 edges) (nth 1 edges)))))
249 scaled-image)
250 (when (> width window-width)
251 (setq window-height (truncate (* window-height
252 (/ (* 1.0 window-width) width)))))
253 (if (> height window-height)
254 (or (create-image file 'imagemagick nil
255 :height window-height)
256 image)
257 image))))
258
229(defun gnus-html-prune-cache () 259(defun gnus-html-prune-cache ()
230 (let ((total-size 0) 260 (let ((total-size 0)
231 files) 261 files)