Hi,
I'm just wondering if there's a way to limit the color palette of a png image, ie from 256 to 16. I know imagejpeg() function has the quality attribute so I can change the quality of a jpeg from 80 to 20 but see that imagepng() has nothing.
Just wondering if there's a way to limit colors, much appreciated.
Thanks
Limiting Color Palette In PNG Image
Moderator: General Moderators
imagetruecolortopalette() has an option to set the number of colours .. if you copied the image into a true colour GD resource, and then set changed that to a 16 color palette you might be ok. Otherwise you're going to have to change the colors using the imagecolorat() and imageallocatecolor() functions..
Note.. the manual comments for imagetruecolortopalette() mention it sometimes doesn't generate the best possible palette.
Note.. the manual comments for imagetruecolortopalette() mention it sometimes doesn't generate the best possible palette.