>If the file mypic.gif already contains 256 different colors then the call to imagecolorallocate() will fail (silently I think).
mypic.gif contains 4 colors only...
>you're assuming that 255,255,255 is actually in the image. It might not be.
I am sure about this, both because I created the images from a script, and because I verified it with
imagecolorat() + imagecolorsforindex() on various (x,y)
I tried adding 'imagecolordeallocate($im, $white);' and re-allocating it with imagecolorallocatealpha($im, 255, 255, 255, 127);
Still fails, being dependent on the initial imagecolorallocate() to set $im.
Hence I tried a different method:
Code: Select all
$src = imagecreatefromgif("original.gif");
$dest = imagecreatetruecolor(190, 190);
//
$white = imagecolorallocate($dest, 255, 255, 255);
imagecolortransparent($dest, $white);
//copy
imagecopy($dest, $src, 0, 0, 0, 0, 190, 190);
echo "done!";
// Output and free from memory
header('Content-Type: image/gif');
imagegif($dest,'copiedOne.gif');
imagedestroy($dest);
imagedestroy($src);
This also fails with all permutations of imagecreate()/imagecreatetruecolor(), imagecolorallocatealpha(); etc