Page 1 of 1
ai to png transparency
Posted: 2010-12-16T09:46:33-07:00
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
Re: ai to png transparency
Posted: 2010-12-16T10:56:30-07:00
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.
Re: ai to png transparency
Posted: 2010-12-16T17:34:17-07:00
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.
Re: ai to png transparency
Posted: 2010-12-16T17:41:47-07:00
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.
Re: ai to png transparency
Posted: 2010-12-16T17:59:46-07:00
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.
Re: ai to png transparency
Posted: 2010-12-16T18:00:51-07:00
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.
Re: ai to png transparency
Posted: 2010-12-16T18:21:26-07:00
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) ?
Re: ai to png transparency
Posted: 2010-12-16T18:47:25-07:00
by magick
Yes try ImageMagick 6.6.6-6 Beta @
ftp://ftp.imagemagick.org/pub/ImageMagick/beta. It has a patch for PNG transparency.
Re: ai to png transparency
Posted: 2010-12-16T20:52:04-07:00
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)
Re: ai to png transparency
Posted: 2010-12-17T02:01:07-07:00
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
Re: ai to png transparency
Posted: 2010-12-17T05:57:12-07:00
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.