Hi I have a project I want to do, and I know GD can do it, but I'm not entirely sure of the steps required. Code examples or a general "this is how you do it, steps 1-5" would be great if anyone has time to share, please.

Let's say I have an image that is 256color GIF or just a JPG. I want someone to be able to upload it, and then I alter the color palette, reducing the number of colors in the pallette drastically, to perhaps only 8. Each color in the original 256 colors would be replaced with the color closest of the new 8 colors available. I know this would make a funky looking image. That's the idea.

What functions do I want to look to at http://us.php.net/gd in order to accomplish this one.

THANKS! 🙂🙂🙂

    Create a new image, [man]imagecolorallocate[/man] the new palette to the new image; fill the rest of the new image's (256-colour) palette with copies of colours from the new palette; [man]imagecopy[/man] the original into it. GD will seek to match the incoming colours to the palette.

    The reason for padding out the new image's palette with copies is because otherwise GD will use unused palette slots for incoming colours.

      Write a Reply...