Subject: ImageMagick and priority of image loaders

From: Glenn Morris <[email-masked]>
Date: Mon, 06 Feb 2012 23:16:21 -0500

Package: emacs
Version: 24.0.93

The Emacs Lisp manual used to say (I'm going to comment it out, for the
reasons given in this report):

    There may be overlap between image loaders in your Emacs
    installation, and you may prefer to use a different one for a given
    image type (which loader will be used in practice depends on the
    priority of the loaders). For example, if you never want to use the
    ImageMagick loader to use JPEG files, add @code{JPG} to this list.

Firstly, I don't understand what this means. What does it means for
there to be multiple "image loaders" in Emacs, and how is their priority
determined? (Also, do I have to add JPEG as well, since
imagemagick-types returns both JPG and JPEG?)

I think it might mean, eg jpeg images can be loaded via libjpeg or
ImageMagick. If that is what it means, it could be clearer.

If so, when I view a jpg with Emacs, how can I tell which loader was
used? Maybe from looking at the mode-line in image-mode, which either
says [jpeg] or [imagemagick]?

It seems there's no practical way to control which loader is used:

i) If you compile without jpeg but with ImageMagick, then you simply cannot
view jpegs: http://debbugs.gnu.org/9045

ii) If you compile with both, then libjpeg is always used (AFAICS). This is
despite imagemagick-register-types adding to the front of
image-type-file-name-regexps. When you visit a jpeg file, image-type
first uses image-type-from-file-header to determine the image type, and
this decides it is a jpeg. So imagemagick never gets a change to open
the jpeg. You can make it work by setting image-type-header-regexps to
nil, but that is supposed to be a constant.