gnus-html-put-image: Use gnus-rescale-image
authorJulien Danjou <julien@danjou.info>
Sun, 3 Oct 2010 14:14:58 +0000 (16:14 +0200)
committerJulien Danjou <julien@danjou.info>
Sun, 3 Oct 2010 14:14:58 +0000 (16:14 +0200)
Signed-off-by: Julien Danjou <julien@danjou.info>
lisp/ChangeLog
lisp/gnus-html.el

index 0d7255f..5076cdb 100644 (file)
@@ -1,5 +1,7 @@
 2010-10-03  Julien Danjou  <julien@danjou.info>
 
+       * 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.
 
index bcbf1bd..732fcdd 100644 (file)
@@ -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