[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

DJVU files and ImageMagick

From: Stephen Berman
Subject: DJVU files and ImageMagick
Date: Sat, 02 Feb 2019 23:12:12 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Should the following change be made?

diff --git a/lisp/image.el b/lisp/image.el
index 3aa3b0aa24..ba75bdf034 100644
--- a/lisp/image.el
+++ b/lisp/image.el
@@ -902,7 +902,7 @@ imagemagick-register-types
       (setq imagemagick--file-regexp re))))
 (defcustom imagemagick-types-inhibit
   "List of ImageMagick types that should never be treated as images.
 This should be a list of symbols, each of which should be one of
 the ImageMagick types listed by `imagemagick-types'.  The listed

Here's my reason for asking:

If Emacs is built without ImageMagick support and the ddjvu program
(from DjVuLibre) is found, DJVU files are automatically (via
auto-mode-alist) displayed in doc-view-mode.  If Emacs is built with
ImageMagick support (version 6 or 7), image-mode is used to display DJVU
files, because DJVU is one of the images type imagemagick-register-types
assigns to image-mode and adds the corresponding entry to
auto-mode-alist before the entry using doc-view-mode-maybe.

I build Emacs from master with ImageMagick support, but if I try to
visit a DJVU file (e.g. a ca. 200 page book of about 1.5 MB),
immediately almost all my system's RAM is consumed, bringing Emacs to a
halt, so it doesn't display the file, and I can recover the memory only
by killing Emacs.  In contrast, when I open the same DJVU file from the
shell using the ImageMagick 'display' command, it also uses most of the
system memory for a number of seconds but then does display the file and
I can exit the program normally and recover the memory.  (This is with
ImageMagick 7; I also tried it on another system using ImageMagick 6 and
there, but using 'display' from the shell was the same as the Emacs
behavior: almost all memory was consumed and the process had to be
killed.)  Can anyone here visit a comparably sized DJVU file in Emacs
built with ImageMagick and have it displayed?  If so, maybe my system
just lacks sufficient memory (it has 4GB RAM + 1 GB swap) -- though that
doesn't explain the difference between 'display' and Emacs+ImageMagick
with ImageMagick 7.

I can prevent Emacs from using ImageMagick with DJVU by customizing
either imagemagick-types-inhibit or imagemagick-enabled-types, but if
this is a general issue, maybe the default value of one of these should
be changed to prevent using ImageMagick with DJVU files.  I see that by
default, PDF is in both lists, whereas DJVU is only in the latter (which
comes from imagemagick-types according to what ImageMagick itself claims
to support).  And indeed, when I try to open a PDF file from the shell
with 'display', the process aborts, so I infer that's why PDF was added
to imagemagick-types-inhibit, and hence, if the problem with DJVU I see
is general, the same thing should be done for this file type (i.e., the
above patch).  (I normally view DJVU files in Emacs using the
djvu package from ELPA, which like doc-view uses DjVuLibre programs, not
ImageMagick, so it doesn't have this issue; but if I use C-x C-f or
Dired to visit a DJVU file, I get the problem.)

If this is just a problem of too little memory, an alternative to
changing the default value of imagemagick-types-inhibit is to add a note
to etc/PROBLEMS suggesting to customize this user option.

Steve Berman

reply via email to

[Prev in Thread] Current Thread [Next in Thread]