From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#10112: ImageMagick doesn't display some image formats Date: Fri, 16 Dec 2011 01:57:52 +0200 Organization: JURTA Message-ID: <874nx11j7j.fsf@mail.jurta.org> References: <871usz3jh8.fsf@mail.jurta.org> <87zkfltk13.fsf@mail.jurta.org> <85ehwx2o4v.fsf@iznogoud.viz> <857h2p2nnv.fsf@iznogoud.viz> <87pqghrv9a.fsf@mail.jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1323993942 21027 80.91.229.12 (16 Dec 2011 00:05:42 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 16 Dec 2011 00:05:42 +0000 (UTC) Cc: 10112@debbugs.gnu.org To: Wolfgang Jenkner Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Dec 16 01:05:38 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RbLIv-00058x-2V for geb-bug-gnu-emacs@m.gmane.org; Fri, 16 Dec 2011 01:05:37 +0100 Original-Received: from localhost ([::1]:34985 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RbLIt-0003iP-C6 for geb-bug-gnu-emacs@m.gmane.org; Thu, 15 Dec 2011 19:05:35 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:59102) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RbLIq-0003hz-97 for bug-gnu-emacs@gnu.org; Thu, 15 Dec 2011 19:05:33 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RbLIp-0007iv-7Q for bug-gnu-emacs@gnu.org; Thu, 15 Dec 2011 19:05:32 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:39315) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RbLIp-0007if-4c for bug-gnu-emacs@gnu.org; Thu, 15 Dec 2011 19:05:31 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1RbLKI-0006qo-BC for bug-gnu-emacs@gnu.org; Thu, 15 Dec 2011 19:07:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 16 Dec 2011 00:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 10112 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 10112-submit@debbugs.gnu.org id=B10112.132399396226220 (code B ref 10112); Fri, 16 Dec 2011 00:07:02 +0000 Original-Received: (at 10112) by debbugs.gnu.org; 16 Dec 2011 00:06:02 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RbLJK-0006oq-0V for submit@debbugs.gnu.org; Thu, 15 Dec 2011 19:06:02 -0500 Original-Received: from smarty.dreamhost.com ([208.113.175.8]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RbLJI-0006oR-LA for 10112@debbugs.gnu.org; Thu, 15 Dec 2011 19:06:01 -0500 Original-Received: from ps18281.dreamhostps.com (ps18281.dreamhost.com [69.163.218.105]) by smarty.dreamhost.com (Postfix) with ESMTP id D740A754068; Thu, 15 Dec 2011 16:04:27 -0800 (PST) Original-Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id 9241B451C63A; Thu, 15 Dec 2011 16:04:00 -0800 (PST) In-Reply-To: <87pqghrv9a.fsf@mail.jurta.org> (Juri Linkov's message of "Fri, 25 Nov 2011 00:49:37 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (x86_64-pc-linux-gnu) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Thu, 15 Dec 2011 19:07:02 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:54999 Archived-At: > But this is still a problem. Currently we can't view images supported > by ImageMagick when they are visited from archives. That's because of > the problem you mentioned: there are no ImageMagick headers in > `image-type-header-regexps'. Since we have only filename extensions to detect ImageMagick-only formats, but not file headers, one way to solve this problem is to try matching buffer names when matching file names fails. This can't be done without affecting other functionality, so perhaps this should be postponed to 24.2. > Another problem is that we can't use ImageMagick transformations on > default image types JPEG, GIF, PNG because they are not visited > with the help of ImageMagick. This problem can be fixed without affecting other functionality. It is localized to just one function `imagemagick-register-types' so it's safe to install for 24.1. The patch below does for `image-type-header-regexps' exactly the same thing as already is done for `image-type-file-name-regexps' - adding entries that match ImageMagick image formats. (However, there is one difference where unlike grouping filename regexps into one regexp with `regexp-opt' can't be used to group file header regexps; I don't why but the result of `regexp-opt' matches nothing; maybe because these regexps are quite complicated). === modified file 'lisp/image.el' --- lisp/image.el 2011-09-16 13:46:42 +0000 +++ lisp/image.el 2011-12-15 23:48:03 +0000 @@ -32,7 +32,7 @@ (defgroup image () (defalias 'image-refresh 'image-flush) -(defconst image-type-header-regexps +(defvar image-type-header-regexps `(("\\`/[\t\n\r ]*\\*.*XPM.\\*/" . xpm) ("\\`P[1-6][[:space:]]+\\(?:#.*[[:space:]]+\\)*[0-9]+[[:space:]]+[0-9]+" . pbm) ("\\`GIF8[79]a" . gif) @@ -702,7 +704,14 @@ (defun imagemagick-register-types () (let ((extension (concat "\\." (regexp-opt im-types) "\\'"))) (push (cons extension 'image-mode) auto-mode-alist) (push (cons extension 'imagemagick) - image-type-file-name-regexps))))) + image-type-file-name-regexps)) + (dolist (header-regexp image-type-header-regexps) + (let ((im-type (cdr header-regexp))) + (when (and (member (symbol-name im-type) im-types) + (not (memq (intern (upcase (symbol-name im-type))) + imagemagick-types-inhibit))) + (push (cons (car header-regexp) 'imagemagick) + image-type-header-regexps))))))) (provide 'image)