Hai ,
I just try to change to original color of image to new color but it is not working .i dont know why.
Any can tell why the following code is not working
<?
header('Content-type: image/jpg');
$filename1 = "test.jpg";
$im=imagecreatefromjpeg($filename1);
$width=imagesx($im);
$height=imagesy($im);
$newim=imagecreate($width,$height);
for ($i=0;$i<256;$i++) {
for ($j=0;$j<256;$j++) {
for ($k=0;$k<256;$k++) {
$palette[$l] = imagecolorallocate($newim,$i,$j,$k);
$l++;
}
}
}
$newim=imagecreate($width,$height);
for($i=0;$i<$width;$i++)
{
for($j=0;$j<$height;$j++)
{
$old=imagecolorat($im,$i,$j);
$r1 = ($old >> 16) & 0xFF;
$g1 = ($old >> 8) & 0xFF;
$b1 = $old & 0xFF;
$newone=imagecolorclosest($im,$r1,$g1,$b1);
imagesetpixel($newim,$i,$j,$palette[$newone]);
}
}
imagejpeg($newim);
?>
Thanks in advance.