changeset 112004:7a4b15c4bbed

Revert "gnus-util: rewrite gnus-rescale-image".
author Katsumi Yamaoka <yamaoka@jpl.org>
date Mon, 20 Dec 2010 22:12:30 +0000
parents 2a665aeb6cbc
children 62f897baec0a
files lisp/gnus/ChangeLog lisp/gnus/gnus-util.el
diffstat 2 files changed, 13 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/gnus/ChangeLog	Mon Dec 20 21:11:01 2010 +0100
+++ b/lisp/gnus/ChangeLog	Mon Dec 20 22:12:30 2010 +0000
@@ -14,11 +14,6 @@
 
 	* nnimap.el (nnimap-retrieve-headers): Remove CRLF from the headers.
 
-2010-12-17  Julien Danjou  <julien@danjou.info>
-
-	* gnus-util.el (gnus-rescale-image): Allow to resize images even if
-	they are from file. Can also scale up.
-
 2010-12-17  Andrew Cohen  <cohen@andy.bu.edu>
 
 	* gnus-sum.el (gnus-summary-refer-thread): Simplify code. Restore
--- a/lisp/gnus/gnus-util.el	Mon Dec 20 21:11:01 2010 +0100
+++ b/lisp/gnus/gnus-util.el	Mon Dec 20 22:12:30 2010 +0000
@@ -1983,16 +1983,21 @@
   "Rescale IMAGE to SIZE if possible.
 SIZE is in format (WIDTH . HEIGHT). Return a new image.
 Sizes are in pixels."
-  (when (fboundp 'imagemagick-types)
+  (if (or (not (fboundp 'imagemagick-types))
+	  (not (get-buffer-window (current-buffer))))
+      image
     (let ((new-width (car size))
           (new-height (cdr size)))
-      (unless (= (cdr (image-size image t)) new-height)
-        (setcdr image (plist-put (cdr image) :type 'imagemagick))
-        (setcdr image (plist-put (cdr image) :height new-height)))
-      (unless (= (car (image-size image t)) new-width)
-        (setcdr image (plist-put (cdr image) :type 'imagemagick))
-        (setcdr image (plist-put (cdr image) :width new-width)))))
-  image)
+      (when (> (cdr (image-size image t)) new-height)
+        (setq image (or (create-image (plist-get (cdr image) :data) 'imagemagick t
+                                      :height new-height)
+                        image)))
+      (when (> (car (image-size image t)) new-width)
+        (setq image (or
+                   (create-image (plist-get (cdr image) :data) 'imagemagick t
+                                 :width new-width)
+                   image)))
+      image)))
 
 (defun gnus-list-memq-of-list (elements list)
   "Return non-nil if any of the members of ELEMENTS are in LIST."