AI to PNG Transparency

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
Acestes

AI to PNG Transparency

Post by Acestes »

I had a problem with getting EPS files to convert to PNG files (see here) while maintaining their transparency. I'd just like to say that AI (Adobe Illustrator CS2) files also fail to maintain their transparency when converted to PNG. I've tried the '-colorspace rgb' addition that was mentioned to temporarily fix the EPS bug but unfortunately it didn't seem to work. It's not a major problem as I don't actually need to convert the AI files, but I thought it was worth mentioning in case someone does! :D
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: AI to PNG Transparency

Post by magick »

Post a URL to one or two AI images so we can download and reproduce the problem. Thanks.
Acestes

Re: AI to PNG Transparency

Post by Acestes »

Sorry I meant to post links to example files and forgot.

Here they are

Adobe Illustrator CS
Adobe Illustrator CS2
Adobe Illustrator CS3
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: AI to PNG Transparency

Post by magick »

ImageMagick utilizes the Ghostscript delegate to render Postscript and PDF. The Ghostscript pngalpha device supports transparency but for only one page. Since there is no easy way to determine if a PDF is only one page we use the pnmraw device instead which does not support transparency. Until Ghostscript provides a multi-page device that supports transparency the only solution is to edit delegates.xml and change the ps:color delegate from pnmraw to pngalpha or use the Ghostscript application directly.
Acestes

Re: AI to PNG Transparency

Post by Acestes »

Thank you for the relpy. Changing the XML does fix the problem :) Interestingly I have had a look and Adobe Illustrator doesn't actually support multi-page, so if you did want to convert ai files the change wouldn't have a negative impact. Or at least it wouldn't as long as you didn't want to convert a multi-page document (would that be from a PDF? I can't think of anything else that is multi-page.). I presusme that if you used this all the time then a multi-page document would have it's first page made transparent and then the rest white?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: AI to PNG Transparency

Post by magick »

We have a patch in ImageMagick 6.3.7-9 Beta (available sometime tomorrow) that will display AI images as transparent but only if its explicitly specified as follows:
  • display ai:test3.ai
Acestes

Re: AI to PNG Transparency

Post by Acestes »

Excellent :D

Will it be just the display for now or will it work with convert as well? I take it the program can't be made to recognise the AI images automatically? Do you happen to know if this new patch will also fix the transparency problem with EPS files saved in Imageformat version 2 (as mentioned in this thread)
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: AI to PNG Transparency

Post by magick »

The problem is EPS is the language level. When we checked the specification, transparency was not supported until Level 3. Its possible the language level was not properly reported for the thread you mentioned or we got it wrong. Either way, transparent EPS should render properly with the latest ImageMagick release (assuming your version of Ghostscript supports the pngalpha device).
Acestes

Re: AI to PNG Transparency

Post by Acestes »

Thanks for the info. I have also looked up the specification and like you said only Level 3 supports transparency. Apparently Adobe Illustrator and other programs 'fake' the background transparency in the EPS files, which is why it 'appears' that a Level 2 EPS has a transparent background. I was wondering if there was a 'command' that I could use that would make the white background transparent (as white is not used in any of my images since the printer doesn't understand 'white' ink :lol). I tried to use -transparent white, but it doesn't work unless I save the EPS to the PNG and then re-run the command on the PNG.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: AI to PNG Transparency

Post by magick »

This works for us (using ImageMagick 6.3.7-8):
  • convert logo: logo.eps
    convert -colorspace rgb logo.eps -transparent white logo.png
Acestes

Re: AI to PNG Transparency

Post by Acestes »

Well I don't believe it! I tried that and it wouldn't work, but now it does! I think it's time for a bit of clean up as I'm probably getting versions confused again. Sorry to have been a pain :oops:

All the best and keep up the good work :D
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: AI to PNG Transparency

Post by anthony »

magick wrote:This works for us (using ImageMagick 6.3.7-8):
  • convert logo: logo.eps
    convert -colorspace rgb logo.eps -transparent white logo.png
Be careful, that just replaces any pure white pixels with transparency. It will probably have the side effect of leaving white halos around text and lines.

For alternatives see IM Examples, Text Handling, Postscript.
http://imagemagick.org/Usage/text/#postscript
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Acestes

Re: AI to PNG Transparency

Post by Acestes »

anthony wrote:
magick wrote:This works for us (using ImageMagick 6.3.7-8):
  • convert logo: logo.eps
    convert -colorspace rgb logo.eps -transparent white logo.png
Be careful, that just replaces any pure white pixels with transparency. It will probably have the side effect of leaving white halos around text and lines.

For alternatives see IM Examples, Text Handling, Postscript.
http://imagemagick.org/Usage/text/#postscript
Thanks for the 'halo' info Anthony :D It shouldn't be a problem in my particular case as I'm taking images that are a minimum of 1000px (wide), doing the required conversions and then reducing them to around 100px (wide) max for preview purposes.
Post Reply