PDF to JPG not picking up all layers

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
image007
Posts: 2
Joined: 2012-05-08T08:59:05-07:00
Authentication code: 13

PDF to JPG not picking up all layers

Post by image007 »

Problem: When I convert a PDF to a JPG, it doesn't seem to be picking up all of the layers for some PDFs. The background and text all appear black, while the images in the PDF appear in the JPG no problem.

- convert.exe is called directly from another program so it's command line parameters can't be changed. I've found that the "-flatten" parameter seems to fix this issue.

My question is: Is there any way to add a delegate that says "use -flatten" when converting PDF to JPG?

Thanks!
image007
Posts: 2
Joined: 2012-05-08T08:59:05-07:00
Authentication code: 13

Re: PDF to JPG not picking up all layers

Post by image007 »

I found my answer!

in delegates.xml I changed this line:


<delegate decode="ps:alpha" restrain="True" command=""@PSDelegate@" -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dEPSCrop -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u "-r%s" %s "-sOutputFile=%s" "-f%s" "-f%s""/>

To:

<delegate decode="ps:alpha" restrain="True" command=""@PSDelegate@" -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dEPSCrop -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pnmraw" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u "-r%s" %s "-sOutputFile=%s" "-f%s" "-f%s""/>


Now, there's no need to use -flatten or -layers merge PDFs convert to JPGs without background or alpha layer issues!
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: PDF to JPG not picking up all layers

Post by anthony »

I believe you get the same effect with some of the specific settings.
But really if you are serious about translating from Postscript, you can use Ghostscript yourself, rather than trying to use the IM convenience function.
http://www.imagemagick.org/Usage/text/text/#ghostscript
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply