Page 1 of 1
Vector to PNG with alpha transparency problems
Posted: 2009-05-20T11:58:58-07:00
by rossmeissl
Hello,
I'm having trouble converting a vector file to PNG while preserving alpha transparency. I've tried every possible combination of options I could find on the board, and still no luck.
I've tried starting with all 3 of these file types:
The EPS and PDF always come out with a white background, despite trying the "-colorspace RGB," "-channel RGBA," and "-background none" tricks I have found here.
Here are some examples:
The closest I'm getting is with the SVG, but the resulting PNG inexplicably has a black background with 50% transparency behind the motorcycle.
Thanks in advance.
Re: Vector to PNG with alpha transparency problems
Posted: 2009-05-20T12:15:17-07:00
by magick
Type
- convert -colorspace RGB motorcycle.eps motorcycle.png
identify -verbose motorcycle.png
We get alpha statistics that show levels of transparency:
- alpha:
min: 53713 (0.819608)
max: 65535 (1)
mean: 65525.1 (0.999848)
standard deviation: 301.241 (0.00459664)
kurtosis: 1034.93
skewness: 31.6121
Do you get the same distribution for alpha?
Re: Vector to PNG with alpha transparency problems
Posted: 2009-05-20T12:19:01-07:00
by rossmeissl
Code: Select all
alpha:
min: 53713 (0.819608)
max: 65535 (1)
mean: 65525.1 (0.999848)
standard deviation: 301.241 (0.00459664)
kurtosis: 1034.93
skewness: 31.6121
Full output is at
http://pastie.org/484496
Re: Vector to PNG with alpha transparency problems
Posted: 2009-05-20T12:46:25-07:00
by magick
It appears that the conversion from EPS to PNG is preserving transparency as expected.
Re: Vector to PNG with alpha transparency problems
Posted: 2009-05-20T12:53:00-07:00
by rossmeissl
Thanks for helping me with this!
Unfortunately, here's the output image that resulted from the commands you had me run:
http://banjo.brighterplanet.com/andy/motorcycle.png
As far as I can tell, it's not transparent.
Re: Vector to PNG with alpha transparency problems
Posted: 2009-05-20T12:54:19-07:00
by rossmeissl
For comparison, when I use Illustrator's Save for Web, I get this:
http://banjo.brighterplanet.com/andy/mo ... narrow.png
Re: Vector to PNG with alpha transparency problems
Posted: 2009-05-20T13:04:55-07:00
by magick
If the image is not rendered correctly, the bug is in Ghostscript or the Ghostscript pngalpha device. ImageMagick delegates Postscript rendering to Ghostscript with this command line:
- "gs" -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=0 "-sDEVICE=pngalpha" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -g121x87 "-sOutputFile=/tmp/magick-XX1HoH3Z" "-f/tmp/magick-XXlMwZ7j" "-f/tmp/magick-XXBA8lcE"
Re: Vector to PNG with alpha transparency problems
Posted: 2009-05-20T13:07:18-07:00
by rossmeissl
Any chance you could try that convert command on motorcycle.eps and make sure I'm not just crazy?
Thanks again.
Re: Vector to PNG with alpha transparency problems
Posted: 2009-05-20T13:22:27-07:00
by fmw42
I downloaded your motorcycle.eps and did the following on IM 6.5.4-7 Q16 Mac OSX Tiger (with gs 8.61) and got:
convert motorcycle.eps motorcycle.png
Unknown device: bmpsep8
Unrecoverable error: undefined in .uninstallpagedevice
Operand stack:
defaultdevice
Unknown device: bmpsep8
Unrecoverable error: undefined in .uninstallpagedevice
Operand stack:
defaultdevice
convert: Postscript delegate failed `/var/tmp/magick-DWKZZyaR': No such file or directory @ ps.c/ReadPSImage/741.
convert: motorcycle.eps: invalid TIFF directory; tags are not sorted in ascending order. `TIFFReadDirectory' @ tiff.c/TIFFWarnings/525.
But it produces a partially transparent image:
But if I do
convert -colorspace rgb motorcycle.eps motorcycle2.png
I get a white background:
Re: Vector to PNG with alpha transparency problems
Posted: 2009-05-20T13:34:31-07:00
by rossmeissl
Interesting. Dropping the colorspace argument like you did in your first test results in a white background for me, but runs without errors.
Does anybody have a test EPS with alpha transparency that has been verified to produce a correct PNG? I'd love to try it on my machine.
Re: Vector to PNG with alpha transparency problems
Posted: 2009-05-20T14:40:27-07:00
by fmw42
I had this same problem/error in
viewtopic.php?f=1&t=13753&hilit=bmpsep8 and
viewtopic.php?f=3&t=13723&p=46762&hilit=bmpsep8#p46762
but so far no one has told me how to correct or avoid that error message. There must be some configuration that I need to do to fix it. Perhaps a GS upgrade. But I don't know for sure.
Re: Vector to PNG with alpha transparency problems
Posted: 2009-05-21T14:21:14-07:00
by rossmeissl
For any Googlers landing here: rsvg performs SVG -> PNG-24 (with alpha transparency) conversions flawlessly.
Re: Vector to PNG with alpha transparency problems
Posted: 2009-05-22T14:58:17-07:00
by magick
Use this command to perform SVG -> PNG-24 (with alpha transparency) conversions flawlessly:
- convert -background none motorcycle.svg motorcycle.png
Not sure why it did not work for you. We're using ImageMagick 6.5.2-7, the current release.
Re: Vector to PNG with alpha transparency problems
Posted: 2009-05-26T07:20:27-07:00
by rossmeissl