0
In this example, you load an image, jpg or png, also loads a gif(16colors), the image you want to manipulate copies the color properties of the gif, saves a new one and erases everyone who will not be useful, see at which points Oce will interact with your images, which ones to discard and which to keep saved. The color gif is attached here. You can still choose to save your new image in png or jpg (if the idea is to reduce allocation this is lighter).
$palette = imagecreatefromgif('palette-gif-03.gif');
$source = imagecreatefromjpeg('test-image-01.jpg');
$source_w = imagesx($source);
$source_h = imagesy($source);
$image = imagecreate($source_w, $source_h);
imagepalettecopy($image, $palette);
imagecopy($image, $source, 0, 0, 0, 0, $source_w, $source_h);
header('Content-Type: image/png');
imagepng($image);
imagedestroy($imgage);
imagedestroy($palette);
imagedestroy($source);
?>
It would be good [Dit] your question by putting an example of what you want to get, explain what you tried and what was the difficulty found so that the community can help better.
– Bacco