Is there any method that can apply half of the grayscale effects
(which is similar to CSS3's filter: grayscale(50%);) ?
Found a script something similar what you are looking for..
<?php
function convertImageToGrayscale($source_file, $percentage)
{
$outputImage = ImageCreateFromJpeg($source_file);
$imgWidth = imagesx($outputImage);
$imgHeight = imagesy($outputImage);
$grayWidth = round($percentage * $imgWidth);
$grayStartX = $imgWidth-$grayWidth;
for ($xPos=$grayStartX; $xPos<$imgWidth; $xPos++)
{
for ($yPos=0; $yPos<$imgHeight; $yPos++)
{
// Get the rgb value for current pixel
$rgb = ImageColorAt($outputImage, $xPos, $yPos);
// extract each value for r, g, b
$rr = ($rgb >> 16) & 0xFF;
$gg = ($rgb >> 8) & 0xFF;
$bb = $rgb & 0xFF;
// Get the gray Value from the RGB value
$g = round(($rr + $gg + $bb) / 3);
// Set the grayscale color identifier
$val = imagecolorallocate($outputImage, $g, $g, $g);
// Set the gray value for the pixel
imagesetpixel ($outputImage, $xPos, $yPos, $val);
}
}
return $outputImage;
}
$image = convertImageToGrayscale("otter.jpg", .25);
header('Content-type: image/jpeg');
imagejpeg($image);
?>
See if that works. I found that here