Transparency lost in PDF to PNG

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
Lincon
Posts: 1
Joined: 2019-05-10T00:52:09-07:00
Authentication code: 1152

Transparency lost in PDF to PNG

Post by Lincon »

Hello everyone,,
I'm reading a PDF file (adobe illustrator) and trying to save it as png

Code: Select all

$img->read('logo.ai');
$img->write('logo.png');

The probleme is that I'm loosing all the transparency and semi-transparency

using instead:
$img->read('logo.ai');
$img->Transparent('color' => 'white');
$img->write('logo.png');
doesn't resolve the problem for the semi-transparency.

What are the correct PerlMagick (ver: 6.5.1.1) settings to use?

Sincerly
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Transparency lost in PDF to PNG

Post by fmw42 »

Best to post a link to your AI file so we can test with it. But if it is CMYK, then you will need to read it in as RGB using the PerlMagick equivalent of

Code: Select all

convert -colorspace sRGB logo.ai ....
Imagemagick uses Ghostscript to read PDF, PS, AI etc. But Ghostscript cannot handle CMYK with alpha.
angelagates29
Posts: 1
Joined: 2019-06-09T08:29:10-07:00
Authentication code: 1152

Re: Transparency lost in PDF to PNG

Post by angelagates29 »

If you apply transparency to objects on a spread, all colors on that spread convert to the transparency blend space you’ve chosen (Edit > Transparency Blend Space), [https://www.pornjk.com/tags/spankbang/]Spankbang[/https://www.pornjk.com/tags/spankbang/] either Document RGB or Document CMYK, even if they’re not involved with transparency. Converting all the colors results in consistency across any two same-colored objects on a spread, and avoids more dramatic color behavior at the edges of transparency.
The above advice seems to imply only that it is bad to mix RGB and CMYK handling where transparency is concerned. (I would really love to understand what means that beautiful rhetoric of "edges of transparency".)
But the following text is more specific:
Depending on your workflow, do one of the following:
If you create documents for print only, choose Document CMYK for the blend space.
If you create documents for web only, choose Document RGB.
If you create documents for both print and web, decide which is more important, and then choose the blend space that matches the final output.
I would therefore advise to convert your images and blend space to CMYK. I do not know if that will help in your case, as the above article only gives hints which it does not explain.
Note that JPEG and PNG images are RGB. TIFF is better adapted to CMYK.
Post Reply