Create a new truecolor (t) image resource with the same dimensions as the original image, and then copy (s) to (t).
eg. (without error handling):
$imgSource = imagecreatefromgif('xyz.gif');
$width = imagesx($imgSource);
$height = imagesy($imgSource);
$imgTC = imagecreatetruecolor($width, $height);
imagecopy($imgTC, $imgSource, 0, 0, 0, 0, $width, $height);
// save or send $imgTC
You will have both images in memory in gd2 format (4 bytes per pixel? 5?), So you better check memory_limit before trying this with large images.
source
share