Converting PDF to PNG produces missing low opacity elements

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
luchin
Posts: 4
Joined: 2017-06-07T01:46:42-07:00
Authentication code: 1151

Converting PDF to PNG produces missing low opacity elements

Post by luchin »

Hi guys,
I'm trying to convert some PDF pages to PNG images, but some pages with low opacity elements and shapes are not correctly generated.
Here's a jpg of the original page saved with gimp : https://www.dropbox.com/s/4u1ce6w3lrrh9 ... l.png?dl=0
Trying to convert (adding colorspace since PDF embeds CMYK colorspace) with the following:

Code: Select all

convert -density 400 -colorspace cmyk input_pdf[73] -resize 25% pag73.png
And this is the result: https://www.dropbox.com/s/7fma247xnsg13 ... d.png?dl=0
- Tried omitting colorspace option and adding CMYK and sRGB profiles, with no luck.
- Tried to edit delegates.xml file with -dUseCIEColor=false, with no difference.
- Tried "-alpha on" option after input file.
Here's an output of

Code: Select all

identify -verbose input_file[73].pdf
https://www.dropbox.com/s/14yrf14up6nnz ... y.txt?dl=0

Any ideas?
Any help would be appreciated...
Thanks

I'm using ImageMagick 6.8.9-9 Q16 x86_64 2017-05-23 running on Debian Linux 8 (jessie)
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Converting PDF to PNG produces missing low opacity elements

Post by snibgo »

What version of Ghostscript are you using?

Can you post the input PDF?

Does it have transparency? Adobe Reader can show this.
snibgo's IM pages: im.snibgo.com
luchin
Posts: 4
Joined: 2017-06-07T01:46:42-07:00
Authentication code: 1151

Re: Converting PDF to PNG produces missing low opacity elements

Post by luchin »

Thank you snibgo,
I'm using gs 9.06
The PDF seems to have transparency, the "show transparency grid" in Adobe reader shows the page objects anchored on a transparent layer.
Unfortunately i can't post the original PDF since it's a technical document not yet published...
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Converting PDF to PNG produces missing low opacity elements

Post by snibgo »

That GS is quite old. I suggest you upgrade it.

Are the objects also semi-transparent?

You might also "+write info:" after reading the PDF, and save to a TIFF so you don't get automatic conversion to sRGB, and "-verbose" to see what command is given to GS:

Code: Select all

convert -verbose -density 400 -colorspace cmyk input_pdf[73] +write info: -resize 25% pag73.tiff
Then you can experiment with "-colorspace sRGB", and/or "-background Blue" before the PDF, etc.
snibgo's IM pages: im.snibgo.com
luchin
Posts: 4
Joined: 2017-06-07T01:46:42-07:00
Authentication code: 1151

Re: Converting PDF to PNG produces missing low opacity elements

Post by luchin »

On Debian Jessie that version is the latest available on the stable repositories...
The objects are also semi-transparent.
The output when trying to write tiff file hasn't worked producing an error: (gimp)
"Warning:
The image you are loading has 16 bits per channel. GIMP can only handle 8 bit, so it will be converted for you. Information will be lost because of this conversion.
Unsupported layout, no RGBA loader"

Output to png:

Code: Select all

convert -verbose -density 400 sfogliabile_deformazione_n230_prova.pdf[73] +write info:file.txt -resize 25% immagini/pag73c.png

Code: Select all

"gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pam" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r400x400" -dUseCIEColor -dFirstPage=74 -dLastPage=74 "-sOutputFile=/tmp/magick-18046z7LVyQGljIpF%d" -dUseCIEColor=false "-f/tmp/magick-18046D37Fuu7jH8JV" "-f/tmp/magick-18046Xp3TQRIBFE4b"
/tmp/magick-18046z7LVyQGljIpF1 PAM 3783x4649 3783x4649+0+0 8-bit ColorSeparation CMYK 70.35MB 0.140u 0:00.140
sfogliabile_deformazione_n230_prova.pdf[73]=>sfogliabile_deformazione_n230_prova.pdf[73] PAM 3783x4649 3783x4649+0+0 16-bit ColorSeparation CMYK 0.000u 0:00.000
sfogliabile_deformazione_n230_prova.pdf[73]=>immagini/pag73c.png[73] PAM 3783x4649=>946x1162 946x1162+0+0 16-bit sRGB 2.046MB 4.150u 0:01.350
link to info.txt: https://www.dropbox.com/s/96plk21mc8wc2rm/file.txt?dl=0
Changing to "background blue" and "colorspace srgb" didn't produce any differences...
luchin
Posts: 4
Joined: 2017-06-07T01:46:42-07:00
Authentication code: 1151

Re: Converting PDF to PNG produces missing low opacity elements

Post by luchin »

Edit: Updated to Gs 9.21 by compiling it from source. Now the output graphics is correct.
Thank you for support
Post Reply