Hey,
I am trying to set up a script to remove the white background from an image and make it transparent.
I managed to almost do this in GD by doing the following:
function maketransparent($oldfile,$newfile)
{
$im = imagecreatefromjpeg($oldfile);
$img = imagecreatetruecolor(500,424);
$trans = imagecolorallocate($img, 0xFF, 0xFF, 0xFF);
imagecolortransparent($img,$trans);
imagecopy($img,$im,0,0,0,0,500,424);
imagetruecolortopalette($img, true, 256);
imageinterlace($img);
imagepng($img,$newfile);
imagedestroy($img);
}
That works however it only removes parts of the image that are exactly White (#FFFFFF), I need some sort of threshold so that it removes colours that are near white aswell.
Does anyone have an idea of how to do this?
Thanks Very much, Max