2

I have a problem with ImageMagick and Ghostscript converting PDF to JPG. Sometimes I get the dreaded

convert multipage.pdf multipage.jpg    
convert: no images defined `multipage.jpg' @ error/convert.c/ConvertImageCommand/3210.
  • It works with only some PDFs, seems to be PDF1.3 only, not sure.
  • ImageMagick-delegates are correct to Ghostscript as I can see (otherwise it should not work at all).
  • Ghostscript seems to work. I run and get a excepted output

    gs -dNOPAUSE -dBATCH -sDEVICE=jpeg -r96 -sOutputFile='page-%00d.jpg' multipage.pdf
    

Is there a problem with the call to Ghostscript from ImageMagick? Is there a log? Is my Ubuntu-installation missing something like a fonts or other stuff?

Have tried to reinstall Ghostscript and ImageMagick many times.

Running Ubuntu 16.04

Any hints appreciated!

1 Answer 1

0

I'm not sure if you found a solution, and also aware this is a very old post and since there might be someone else needing an insight on this, I would like to share a possible solution.

As an assumption. It seems like you are trying to work with a document that has more than one page. Neither is clear if the other PDF the command worked on were single page.

But based on assumptions only, just want to clarify, I'm guessing that the only issue with your command is not specifying what page of the PDF document you intend to convert into an image. As in many tutorials throughout the web, you have to do something like this:

convert "multipage.pdf[0]" multipage.jpg

The command is specifying that the first page would be rendered as an image then converted into a JPEG file.

Now also be aware, that new installations of ImageMagick prohibit the process of PostScript files. If you get an error like the following:

attempt to perform an operation not allowed by the security policy `PDF' @ error/constitute.c/IsCoderAuthorized/408

You need to open the policy.xml file which is located at /etc/ImageMagick-6 depending on version installed, and comment the following statements:

<!-- disable ghostscript format types -->
<policy domain="coder" rights="none" pattern="PS" />
<policy domain="coder" rights="none" pattern="PS2" />
<policy domain="coder" rights="none" pattern="PS3" />
<policy domain="coder" rights="none" pattern="EPS" />
<policy domain="coder" rights="none" pattern="PDF" />
<policy domain="coder" rights="none" pattern="XPS" />

But be aware, this is a very important note, if you have an older version of GhostScript installed this is not recommended since there's a serious security hole for older versions. I recommend to always keep GhostScript and ImageMagick always up to date and fix your code accordingly.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .