Convert to PNG using a specific palette?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
summer
Forum Newbie
Posts: 1
Joined: Mon Jul 08, 2002 6:54 am

Convert to PNG using a specific palette?

Post by summer »

I'm doing a site that has more than one interface/skins. Apart from the standard truecolor skin I have a 2 color b/w, 16 and 32 colors options. The problem is when I'm adding new graphical content - the thumbnails will always stand out because they are truecolor.

Is there a way to convert to multiple files having different user specified palettes using GDLIB?

Using the imagepalettecopy function seems to have no effect. I tried using it on 24bit png => 8bit indexed png and 8bit index png => 2bit index png.

Here's the code:


PHP:--------------------------------------------------------------------------------

Code: Select all

header("Content-type: image/png");
$im_orig = imagecreatefrompng("shrek_p2.png");
$im_copy = imagecreatefrompng("shrek2.png");
// copy the palette
imagepalettecopy($im_orig, $im_copy);
imagepng($im_copy);
imagedestroy($im_copy);
--------------------------------------------------------------------------------



Thanks in advance
- Summer
Post Reply