GNU bug report logs - #29584
imagemagick-types-inhibit does not result in correct image backend (minor)

Previous Next

Package: emacs;

Reported by: adam plaice <plaice.adam+lists <at> gmail.com>

Date: Tue, 5 Dec 2017 21:13:01 UTC

Severity: normal

Tags: fixed

Found in version 26.0.90

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 29584 in the body.
You can then email your comments to 29584 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#29584; Package emacs. (Tue, 05 Dec 2017 21:13:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to adam plaice <plaice.adam+lists <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 05 Dec 2017 21:13:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: adam plaice <plaice.adam+lists <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: imagemagick-types-inhibit does not result in correct image backend
 (minor)
Date: Tue, 5 Dec 2017 21:12:07 +0000
If emacs was compiled with both imagemagick and specific image type
backend support (e.g. librsvg, libpng), then imagemagick-types-inhibit
has no effect on the backend used for the given image types (e.g. svg, png).

* To reproduce

1. With emacs -Q, evaluate:

(setq imagemagick-types-inhibit t)
(imagemagick-register-types)

(Alternatively and equivalently, customize imagemagick-types-inhibit
to t, or place the above two lines in init.el.)

2. Open a png file in emacs. For instance:

wget https://upload.wikimedia.org/wikipedia/commons/d/d9/Test.png

C-x C-f Test.png RET

* Expected result

The image is opened in image-mode, using the libpng backend (and
(Image[png]) is displayed in the mode-line).

* Actual result

The image is opened in image-mode, using the imagemagick backend (and
(Image[imagemagick]) is displayed in the mode-line), despite
imagemagick-types-inhibit having been set to `t'.

According to both the docstring of imagemagick-types-inhibit and the Texinfo
manual ((elisp) ImageMagick Images), imagemagick-types-inhibit should prevent
imagemagick from being used for the given image type (or overall for t).


* Discussion and speculation

This is obviously a very minor bug, since it's only a matter of the
choice of backend and it only came up when investigating #29581, where
it was interesting to determine the effect of different backends.


I think that the issue is caused by these lines (in the definition of
image-toggle-display-image in image-mode.el):

     (type (if (fboundp 'imagemagick-types)
           'imagemagick
         (image-type file-or-data nil data-p)))

https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/image-mode.el?h=emacs-26#n761

It seems that if imagemagick is available, then irrespective of the
value of imagemagick-types-inhibit, the imagemagick backend will
always be used.

If alternative backends (libpng etc.) were not compiled in,
imagemagick-types-inhibit set to `t' would have caused image-mode not
to be present in the auto-mode-alist, meaning that image-mode would
not be activated by default and imagemagick-types-inhibit would act as
expected.  However, when these other backends are compiled in, then
they modify the auto-mode-alist, causing image-mode to be used for
.png or .svg files, despite the fact that once image-mode is launched,
the imagemagick backend will be used.


I'm not sure what is the right solution in this case. The easiest
would be to update the documentation to the current state of
affairs.  OTOH being able to easily set the image backend is
occasionally nice to have.

Thank you and best regards,
Adam


In GNU Emacs 26.0.90 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.18.9)
 of 2017-12-05 built on adam
Repository revision: 46d62b9f36f1ef771a077df4227ae6559fb32e84
Windowing system distributor 'The X.Org Foundation', version 11.0.11804000
System Description:    Ubuntu 16.04.3 LTS

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.

Configured using:
 'configure --with-modules --without-pop'

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY
ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 MODULES LIBSYSTEMD LCMS2

Important settings:
  value of $LANG: en_GB.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny seq byte-opt gv
bytecomp byte-compile cconv cl-loaddefs cl-lib dired dired-loaddefs
format-spec rfc822 mml easymenu mml-sec password-cache epa derived epg
epg-config gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047
rfc2045 ietf-drums mm-util mail-prsvr mail-utils elec-pair time-date
mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar
dnd fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode elisp-mode lisp-mode prog-mode register page menu-bar
rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core term/tty-colors frame cl-generic cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese composite charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote dbusbind inotify lcms2
dynamic-setting system-font-setting font-render-setting move-toolbar gtk
x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 94561 8308)
 (symbols 48 20332 1)
 (miscs 40 42 118)
 (strings 32 28247 1513)
 (string-bytes 1 744109)
 (vectors 16 13967)
 (vector-slots 8 491974 7546)
 (floats 8 50 67)
 (intervals 56 219 0)
 (buffers 992 12)
 (heap 1024 35241 1000))




bug Marked as found in versions 26.0.90. Request was from Adam Plaice <plaiceadam <at> gmail.com> to control <at> debbugs.gnu.org. (Tue, 05 Dec 2017 21:23:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29584; Package emacs. (Wed, 06 Dec 2017 18:27:04 GMT) Full text and rfc822 format available.

Message #10 received at 29584 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: adam plaice <plaice.adam+lists <at> gmail.com>
Cc: 29584 <at> debbugs.gnu.org
Subject: Re: bug#29584: imagemagick-types-inhibit does not result in correct
 image backend (minor)
Date: Wed, 06 Dec 2017 13:25:54 -0500
adam plaice wrote:

> I think that the issue is caused by these lines (in the definition of
> image-toggle-display-image in image-mode.el):
>
>      (type (if (fboundp 'imagemagick-types)
>            'imagemagick
>          (image-type file-or-data nil data-p)))

Yes, see:

http://lists.gnu.org/archive/html/emacs-diffs/2014-08/msg00039.html
http://lists.gnu.org/archive/html/emacs-devel/2014-08/msg00101.html

    This may be a kinda controversial change, since it now defaults to
    using imagemagick for images, if you have support for imagemagick.

    But this makes it possible to browse a typical
    directory-of-images-from-your-camera just by hitting `n' a lot, without
    a lot of futzing around, so I think it's a net win.

    Perhaps there should be an option to disable it if it annoys people.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29584; Package emacs. (Wed, 06 Dec 2017 19:33:02 GMT) Full text and rfc822 format available.

Message #13 received at 29584 <at> debbugs.gnu.org (full text, mbox):

From: Adam Plaice <plaiceadam <at> gmail.com>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 29584 <at> debbugs.gnu.org
Subject: Re: bug#29584: imagemagick-types-inhibit does not result in correct
 image backend (minor)
Date: Wed, 6 Dec 2017 19:32:12 +0000
Thanks for the clarification.

As it's a deliberate change and to avoid over-complication that nobody
usually needs (if one generally dislikes the imagemagick backend then
one should use a version of emacs compiled without it, and in the very
rare case when one does need to change the backend on the fly, one can
just override image-toggle-display-image), leaving the code alone is
probably the best option.

However, I'd argue that the documentation should be updated — the
docstring of imagemagick-types-inhibit already contains extensive
warnings

"
If you change this without using customize, you must call
‘imagemagick-register-types’ afterwards.

If Emacs is compiled without ImageMagick support, this variable
has no effect.
"

so another sentence to the effect of "If emacs is compiled with
alternative image backends, in addition to ImageMagick support, this
variable also has no effect." wouldn't be out place (and since there
are already extensive warnings, creating an impression of
completeness, the absence of an important warning — having multiple sets
of backends is probably the most frequent situation on GNU/Linux —
would be confusing).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29584; Package emacs. (Wed, 06 Dec 2017 20:18:02 GMT) Full text and rfc822 format available.

Message #16 received at 29584 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Adam Plaice <plaiceadam <at> gmail.com>
Cc: Glenn Morris <rgm <at> gnu.org>, 29584 <at> debbugs.gnu.org
Subject: Re: bug#29584: imagemagick-types-inhibit does not result in correct
 image backend (minor)
Date: Wed, 06 Dec 2017 21:17:34 +0100
Adam Plaice <plaiceadam <at> gmail.com> writes:

> As it's a deliberate change and to avoid over-complication that nobody
> usually needs (if one generally dislikes the imagemagick backend then
> one should use a version of emacs compiled without it, and in the very
> rare case when one does need to change the backend on the fly, one can
> just override image-toggle-display-image), leaving the code alone is
> probably the best option.

I think it probably wouldn't be very difficult to make image-mode
respect that variable, and that would probably be the nicest fix here...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29584; Package emacs. (Sat, 14 Apr 2018 13:38:01 GMT) Full text and rfc822 format available.

Message #19 received at 29584 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Adam Plaice <plaiceadam <at> gmail.com>
Cc: Glenn Morris <rgm <at> gnu.org>, 29584 <at> debbugs.gnu.org
Subject: Re: bug#29584: imagemagick-types-inhibit does not result in correct
 image backend (minor)
Date: Sat, 14 Apr 2018 15:37:05 +0200
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Adam Plaice <plaiceadam <at> gmail.com> writes:
>
>> As it's a deliberate change and to avoid over-complication that nobody
>> usually needs (if one generally dislikes the imagemagick backend then
>> one should use a version of emacs compiled without it, and in the very
>> rare case when one does need to change the backend on the fly, one can
>> just override image-toggle-display-image), leaving the code alone is
>> probably the best option.
>
> I think it probably wouldn't be very difficult to make image-mode
> respect that variable, and that would probably be the nicest fix here...

I've now done so in Emacs 27.1.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 14 Apr 2018 13:38:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 29584 <at> debbugs.gnu.org and adam plaice <plaice.adam+lists <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 14 Apr 2018 13:38:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29584; Package emacs. (Sun, 15 Apr 2018 11:27:01 GMT) Full text and rfc822 format available.

Message #26 received at 29584 <at> debbugs.gnu.org (full text, mbox):

From: Adam Plaice <plaiceadam <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 29584 <at> debbugs.gnu.org
Subject: Re: bug#29584: imagemagick-types-inhibit does not result in correct
 image backend (minor)
Date: Sun, 15 Apr 2018 13:26:43 +0200
Great! Thanks!




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 14 May 2018 11:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 5 years and 347 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.