开发者

Converting a PNG-24 with per-pixel transparency to PNG-8

开发者 https://www.devze.com 2023-02-02 09:25 出处:网络
Is it possible to take a 24 bit PNG with per-pixel alpha values and convert this into a 8 bit PNG while maintaining the transparency? The original image only contains a max of 256 colour so this shoul

Is it possible to take a 24 bit PNG with per-pixel alpha values and convert this into a 8 bit PNG while maintaining the transparency? The original image only contains a max of 256 colour so this should be possible, righ开发者_开发问答t?

---- The rationale:

I'm working on an image cropper in Actionscript which posts encoded bytearrays to PHP to be created as files on the file system.

Unfortuantely ActionScript doesn't support GIF Encoding so when dealing with a gif with transparency we have to PNG encode it in Actionscript before posting it to PHP. We can then save it as a PNG and maintain the transparency by using the imagealphablending and imagesavealpha functions.

The issue with this is the filesize is a lot bigger than the original gif. This is presumably because the colourspace is now true colour rather than the GIF indexed pallete.


PNG-8 can have variable alpha transparency, but each color including its alpha gets indexed in the available number of colors.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号