I hope someone can help,
I have made a script that masks images... however it is reliant on a colour to mask with ( \'green screen\' style). The trouble is if the im
Here is the replace colour solution that first converts to 256 pallet:
//Open Image
$Image = imagecreatefromJPEG('input.jpg') or die('Problem with source');
//set the image to 256 colours
imagetruecolortopalette($Image,0,256);
//Find the Chroma colour
$RemChroma = imagecolorexact( $Image, 0,0,255 );
//Replace Chroma Colour
imagecolorset($Image,$RemChroma,0,0,254);
//Use function to convert back to true colour
imagepalettetotruecolor($Image);
function imagepalettetotruecolor(&$img)
{
if (!imageistruecolor($img))
{
$w = imagesx($img);
$h = imagesy($img);
$img1 = imagecreatetruecolor($w,$h);
imagecopy($img1,$img,0,0,0,0,$w,$h);
$img = $img1;
}
}
I personally prefer radio4fans solution as it is lossless, but if speed is your goal this is superior.