unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: Wolfgang Jenkner <wjenkner@inode.at>
Cc: 10112@debbugs.gnu.org
Subject: bug#10112: ImageMagick doesn't display some image formats
Date: Fri, 16 Dec 2011 01:57:52 +0200	[thread overview]
Message-ID: <874nx11j7j.fsf@mail.jurta.org> (raw)
In-Reply-To: <87pqghrv9a.fsf@mail.jurta.org> (Juri Linkov's message of "Fri, 25 Nov 2011 00:49:37 +0200")

> 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)





  reply	other threads:[~2011-12-15 23:57 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-22 22:01 bug#10112: ImageMagick doesn't display some image formats Juri Linkov
2011-11-24 19:09 ` Juri Linkov
2011-11-24 21:42   ` Wolfgang Jenkner
2011-11-24 21:52     ` Wolfgang Jenkner
2011-11-24 22:49       ` Juri Linkov
2011-12-15 23:57         ` Juri Linkov [this message]
2012-06-13 23:57           ` Juri Linkov
2014-12-08 23:32           ` Lars Magne Ingebrigtsen
2014-12-09  0:58             ` Juri Linkov
2014-12-09  1:18               ` Lars Magne Ingebrigtsen
2011-12-15 23:32   ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874nx11j7j.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=10112@debbugs.gnu.org \
    --cc=wjenkner@inode.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).