PDF with transparency gets reversed or washed out

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
mstucka
Posts: 3
Joined: 2013-07-29T06:49:21-07:00
Authentication code: 6789

PDF with transparency gets reversed or washed out

Post 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?
mstucka
Posts: 3
Joined: 2013-07-29T06:49:21-07:00
Authentication code: 6789

Re: PDF with transparency gets reversed or washed out

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: PDF with transparency gets reversed or washed out

Post by snibgo »

Can you supply a sample PDF that gives the problem?
snibgo's IM pages: im.snibgo.com
mstucka
Posts: 3
Joined: 2013-07-29T06:49:21-07:00
Authentication code: 6789

Re: PDF with transparency gets reversed or washed out

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: PDF with transparency gets reversed or washed out

Post 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
snibgo's IM pages: im.snibgo.com
Post Reply