ImageMagick scripts error when run from within Calibre

Bug #1389449 reported by Jeff on 2014-11-05
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

One of the many uses I have found for Calibre is storing batch (*.bat) scripts I have written. Typically, double clicking on a script in Calibre or using the V shortcut runs the batch script. However, whenever I run a batch script that uses an ImageMagick program (convert.exe, conjure.exe, etc.) via either of the methods above, I get an error message.

For instance, a batch file with the following single line of text:

start "" "C:\Windows\System32\cmd.exe" /k ""C:\Program Files\ImageMagick-6.8.9-Q16\convert.exe" "C:\Users\owner\Desktop\image.png" "C:\Users\owner\Desktop\image.jpg""

I get the following error message:

convert.exe: unable to load module 'C:\Program Files (x86)\Calibre2\DLLs\IM_MOD_RL_PNG_.dll': An unkown error ocurred @ error/module.c/OpenModule/1282.
convert.exe: no decode delegate for this image format 'PNG' @ error/constitute .c/ReadImage/501.
convert.exe: no images defined 'C:\Users\owner\Desktop\image.jpg' @ error/convert.c/ConvertImageCommand/3210.

If I select Calibre's "open containing folder" option and then run the batch file from the resulting Windows Explorer window, it works perfectly with no error. If I manually paste the batch's text into a command prompt, it works perfectly with no error. The only time there is an issue is when I run the batch file from within Calibre using one of the two methods outlined above.

I am using the latest Calibre version 2.8.0 as well as the latest ImageMagick version 6.8.9-10-Q16

Appreciate any help you can offer.

You will need to sanitize the various IMAGEMAGICK environment variables
that calibre sets (and which subprocesses launched from calibre will
inherit) in your batch script. IIRC, they are


 status fixreleased

Changed in calibre:
status: New → Fix Released
Jeff (annoywife) wrote :

Just installed 2.9 and tried executing the above batch file form within Calibre. Got the exact same error message as before (quoted above). Could the fix have not gotten in as designed?

Kovid Goyal (kovid) wrote :

Simply unset those environment variables in your bat file before calling convert.exe

Jeff (annoywife) wrote :

I understand the part about unsetting ImageMagick variables in the script (btw, all I had unset in mine to make it function properly was MAGICK_CODER_MODULE_PATH - thanks very much for listing above the possible variables to try). Just want to ensure that there is awareness that this bug has not in fact been fixed in Calibre itself - for transparency, I suggest that the the status of this bug either (1) be set to wontfix if the code is expected to remain as it is in 2.9 or (2) remain as Fix Released if the issue is to be truly fixed in Calibre code.

Thanks again for the guidance.

Kovid Goyal (kovid) wrote :

It is fixed, the fix is simply not in 2.9

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers