Page 1 of 1

PDF with transparency gets reversed or washed out

Posted: 2013-07-29T06:57:02-07:00
by mstucka
I'm having problems converting some PDFs to JPG that apparently have transparency in them, which causes some of the colors to reverse. Elsewhere, I'd been told to try
-flatten , -alpha flatten or -alpha remove. This takes care of the reversing problem.

Unfortunately, in at least one case, it's also starts washing out my images, such that even black type becomes gray. Any ideas? Here's the last line I was using:
/home/mstucka/bin/convert a.pdf -alpha remove -gravity center -background white -resize x403 -extent 202x403 a.jpg

A straight conversion without resizing still causes the washing out. Some images process perfectly and can be composited with the faulty ones, e.g.:
Image

Any ideas on what to try?

Re: PDF with transparency gets reversed or washed out

Posted: 2013-07-29T07:24:37-07:00
by mstucka
I tried kicking this around in ImageMagick more, then saw where ImageMagick and Ghostscript really have different abilities. So a Ghostscript fix worked, e.g., pdf2ps, then using IM's convert to convert into JPG with the resizing and padding I've wanted. Apparently PostScript has no support for transparency, so Ghostscript's conversion to PostScript strips off the transparency:

Total command line to take three PDFs, convert, and stick into two pairs:

Code: Select all

/home/mstucka/bin/pdf2ps a.pdf a.ps
/home/mstucka/bin/pdf2ps b.pdf b.ps
/home/mstucka/bin/pdf2ps c.pdf c.ps
/home/mstucka/bin/convert a.ps -alpha remove -gravity center -background white -resize x403 -extent 202x403 a.jpg
/home/mstucka/bin/convert b.ps -alpha remove -gravity center -background white -resize x403 -extent 201x403 b.jpg
/home/mstucka/bin/convert c.ps -alpha remove -gravity center -background white -resize x403 -extent 201x403 c.jpg
/home/mstucka/bin/convert a.jpg b.jpg +append ab.jpg
/home/mstucka/bin/convert a.jpg c.jpg +append ac.jpg

Re: PDF with transparency gets reversed or washed out

Posted: 2013-07-29T08:04:39-07:00
by snibgo
Can you supply a sample PDF that gives the problem?

Re: PDF with transparency gets reversed or washed out

Posted: 2013-07-29T08:10:15-07:00
by mstucka
Thanks for taking an interest! I think this'll let you at the original file -- download with control-S, supposedly:
https://docs.google.com/file/d/0ByagJWt ... sp=sharing

Re: PDF with transparency gets reversed or washed out

Posted: 2013-07-29T08:54:25-07:00
by snibgo
The image has dark text on a transparent background.

Using IM v6.8.6-0 on Windows 7, a simple conversion ...

Code: Select all

convert 0726.pdf p.png
... gives me a result with visually the same colours and tones as Adobe Reader X v10.1.7. I can't see any difference.

The above command leaves the transparent areas transparent. To turn them white:

Code: Select all

convert 0726.pdf -background White -alpha Remove p.png