From 3d7f4977aa5a8cb288ff8622cc9a03ae021b8f78 Mon Sep 17 00:00:00 2001 From: Tadashi MATSUO Date: Sat, 9 Jan 2010 00:17:09 +0900 Subject: [PATCH] If `convert' is not required, it is not invoked. (twittering-retrieve-image): Do not invoke `convert' if Emacs supports the image type and resize is not required. --- ChangeLog | 2 ++ twittering-mode.el | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0ccd2a87..fc7dcce8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -60,6 +60,8 @@ * twittering-mode.el (twittering-image-type): Try to detect image type with `image-type-from-data' at first. + (twittering-retrieve-image): Do not invoke `convert' if Emacs + supports the image type and resize is not required. 2010-01-08 Yuto Hayamizu diff --git a/twittering-mode.el b/twittering-mode.el index c03c2a55..8c843451 100644 --- a/twittering-mode.el +++ b/twittering-mode.el @@ -1965,7 +1965,10 @@ following symbols; (let ((image-data (gethash `(,image-url . ,twittering-convert-fix-size) twittering-image-data-table))) (when (not image-data) - (let ((image-type nil)) + (let ((image-type nil) + (image-spec nil) + (converted-image-size + `(,twittering-convert-fix-size . ,twittering-convert-fix-size))) (with-temp-buffer (set-buffer-multibyte nil) (let ((coding-system-for-read 'binary) @@ -1974,7 +1977,13 @@ following symbols; (url-insert-file-contents image-url) (setq image-type (twittering-image-type image-url (current-buffer))) - (when (and twittering-convert-fix-size twittering-use-convert) + (setq image-spec `(image :type ,image-type + :data ,(buffer-string))) + (when (and twittering-convert-fix-size twittering-use-convert + (not + (and (image-type-available-p image-type) + (equal (image-size image-spec t) + converted-image-size)))) (call-process-region (point-min) (point-max) twittering-convert-program