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
bdecherf

ai to png transparency

Post by bdecherf »

Hi,

I need to convert image files to png. It works in general, but I lost transparency with the illustrator files.
I'm not sure if I should post this here or in a ghostscript forum ?
The command I use is:
~/opt/imagemagick/bin/convert test.ai -background transparent -alpha on test.png

This is imagemagick 6.6.5-8

The gs executed command is:
"gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" "-sOutputFile=/tmp/magick-XXBlesqU" "-f/tmp/magick-XXdloVsM" "-f/tmp/magick-XXg7UvvE"
You can check the test file here:
http://benoit.boceto.fr/test/test.ai

Which arguments should I use ?

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

Re: ai to png transparency

Post by fmw42 »

It may be the ghostscript device set up in IM (which you can change in one of the xml files, but I don't recall which one).

But you can try

~/opt/imagemagick/bin/convert test.ai -channel rgba -alpha on test.png

Note -background -transparent is a setting and does nothing in your case.
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 »

In this case Set the -channel BEFORE reading the 'ai' image as in this case it is used to switch the postscript generator (ghostscript) to a mode that generate transparency.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
bdecherf

Re: ai to png transparency

Post by bdecherf »

anthony wrote:In this case Set the -channel BEFORE reading the 'ai' image as in this case it is used to switch the postscript generator (ghostscript) to a mode that generate transparency.
Which channel ?
I try with rgba, and it doesn't change the results:
convert -channel rgba test.ai -background transparent -alpha on test.png

The original image should be completly transparent. Using the convert command, I've got a transparent image, but "bound" of the image has a white background.
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 »

For other techniques see...
http://www.imagemagick.org/Usage/test/#postscript


Opps it appears those examples has broken!!! Arrggghhh... Working to fix them.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: ai to png transparency

Post by magick »

Try this:
  • convert ai:test.ai test.png
In the mean-time we'll add a patch to ImageMagick 6.6.6-6 Beta so that you can simply specify test.ai rather than ai:test.ai.
bdecherf

Re: ai to png transparency

Post by bdecherf »

magick wrote:Try this:
  • convert ai:test.ai test.png
In the mean-time we'll add a patch to ImageMagick 6.6.6-6 Beta so that you can simply specify test.ai rather than ai:test.ai.
I have the same results (I've also tried with the version 6.6.6-5). Where can I check the 6.6.6-6 beta version ?
Does it help you if I publish the png exported by photoshop ? (and the one generated by imagemagick) ?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: ai to png transparency

Post by magick »

Yes try ImageMagick 6.6.6-6 Beta @ ftp://ftp.imagemagick.org/pub/ImageMagick/beta. It has a patch for PNG transparency.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: ai to png transparency

Post by fmw42 »

-background transparent as I said before will not do anything for you in this case as it is a setting and not an operation.

I think Anthony is suggesting:

convert -channel rgba -alpha on image.ai image.png

But apparently there is still a bug in PNG transparency that Magick indicates may be fixed in IM 6.6.6.6 beta. Betas are available at ftp://ftp.imagemagick.org/pub/ImageMagick (see the beta folder)
bdecherf

Re: ai to png transparency

Post by bdecherf »

It doesn't work with the 6.6.6-6 2010-12-17
I have the same result:
http://benoit.boceto.fr/test/test.html

The result I should have (made using photoshop):
http://benoit.boceto.fr/test/test-ps.html


This command give me a white background:
convert -channel rgba -alpha on test.ai test.png
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 with Ghostscript, not ImageMagick. ImageMagick uses Ghostscript as a delegate for interpreting Postscript and PDF. If you bypass ImageMagick and use Ghostscript directly from the command line it produces the same result as http://benoit.boceto.fr/test/test.html. Post a bug report to the Ghostscript bug forum if you want a fix to the problem you reported.
Post Reply