From 7efe00a5135dd3a7efdc1ff38734476f1d33a616 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Sun, 3 Oct 2010 16:14:58 +0200 Subject: [PATCH] gnus-html-put-image: Use gnus-rescale-image Signed-off-by: Julien Danjou --- lisp/ChangeLog | 2 ++ lisp/gnus-html.el | 37 +++++++++++-------------------------- 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0d7255fa8..5076cdb91 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,7 @@ 2010-10-03 Julien Danjou + * gnus-html.el (gnus-html-put-image): Use gnus-rescale-image. + * mm-view.el (gnus-window-inside-pixel-edges): Add autoload for gnus-window-inside-pixel-edges. diff --git a/lisp/gnus-html.el b/lisp/gnus-html.el index bcbf1bdd9..732fcdda5 100644 --- a/lisp/gnus-html.el +++ b/lisp/gnus-html.el @@ -431,7 +431,17 @@ Return a string with image data." (= (car size) 30) (= (cdr size) 30)))) ;; Good image, add it! - (let ((image (gnus-html-rescale-image image data size))) + (let ((image (gnus-html-rescale-image + image + ;; (width . height) + (cons + ;; Aimed width + (truncate + (* gnus-max-image-proportion + (- (nth 2 edges) (nth 0 edges)))) + ;; Aimed height + (truncate (* gnus-max-image-proportion + (- (nth 3 edges) (nth 1 edges)))))))) (delete-region start end) (gnus-put-image image alt-text 'external) (gnus-put-text-property start (point) 'help-echo alt-text) @@ -454,31 +464,6 @@ Return a string with image data." (gnus-add-image 'internal image)) nil)))))))) -(defun gnus-html-rescale-image (image data size) - (if (or (not (fboundp 'imagemagick-types)) - (not (get-buffer-window (current-buffer)))) - image - (let* ((width (car size)) - (height (cdr size)) - (edges (gnus-window-inside-pixel-edges - (get-buffer-window (current-buffer)))) - (window-width (truncate (* gnus-max-image-proportion - (- (nth 2 edges) (nth 0 edges))))) - (window-height (truncate (* gnus-max-image-proportion - (- (nth 3 edges) (nth 1 edges))))) - scaled-image) - (when (> height window-height) - (setq image (or (create-image data 'imagemagick t - :height window-height) - image)) - (setq size (image-size image t))) - (when (> (car size) window-width) - (setq image (or - (create-image data 'imagemagick t - :width window-width) - image))) - image))) - (defun gnus-html-image-url-blocked-p (url blocked-images) "Find out if URL is blocked by BLOCKED-IMAGES." (let ((ret (and blocked-images -- 2.25.1