문제

Here is an image: Gradient1
This image is a simple black-to-transparent gradient saved in full RGBA PNG.

Here is the same image, converted to indexed-alpha PNG by GIMP (Photoshop produces the same result)
Gradient2
As you can see, the gradient is now half-opaque, half-transparent.

Here is the same image again, only this time it was converted to indexed-alpha PNG by a PHP script I wrote:
Gradient3

So my question is: Why are GIMP and Photoshop unable to support partial transparency in indexed images, when the PHP script clearly shows that such an image can be created with no problems?
Is there anything "wrong" with an image whose pallette contains alpha information?
A more programming-related question: Does this transparency in the last image work in Internet Explorer 6?

도움이 되었습니까?

해결책 2

I've finally found the actual answer: There is a metadata entry that allows you to define the alpha value of each colour in the colour table. Most graphics programs don't make use of this, but it does exist and can be used, in particular by GD.

다른 팁

For the record, PNG does not literally support indexed images with an alpha channel. What is really happening is that PNG allows you to add additional colors to the color table (i.e. index) with alpha values in those colors... not a complete alpha channel. FWIW...

Another option besides fireworks is pngquant, a command line application that will convert a rgba png into an indexed png with transparency.

I found this post which talks some more about how to use it.

IE6 and earlier in windows does not support variable transparency PNGs without annoying workarounds. An indexed PNG will only show the fully opaque parts which usually works pretty well. A drop shadow would disappear but the opaque parts of the logo or icon would continue to show.

This page has a better explanation and instructions with more png compression and quantization tools: http://calendar.perfplanet.com/2010/png-that-works/

Yeah I know what you mean. Fireworks is the only image editing program that I know of that can create and edit PNG8+Alpha without problems. I wish more paint programs would support this format cause Fireworks is expensive!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top