here is some crappy code that I wrote.
It works, but there has to be a better way to do this.
I did it this way cause on a truecolor image, imagecolorstotal($im); doesn't work and returns a 0.
Anyone know a work around so I can use imagecolorset?
tia
$im_size = GetImageSize ($original);
$imageWidth = $im_size[0];
$imageHeight = $im_size[1];
if (stristr($original, ".png") != "")
$im = imagecreatefrompng ($original);
else
$im = ImageCreateFromJPEG($original);
for($x=0;$x < $imageWidth;$x++)
{
for($y=0;$y < $imageHeight;$y++)
{
$rgb = ImageColorAt($im, $x, $y);
$rgb = imagecolorsforindex($im,$rgb);
$t = ($rgb["red"]+$rgb["green"]+$rgb["blue"])/3;
imagesetpixel ($im, $x, $y, ($t<<16)+($t<<8)+$t);
}
}
if (stristr($original, ".png") != "")
{
header("Content-type: image/Png");
ImagePNG($im,null);
}
else
{
header("Content-type: image/jpeg");
Imagejpeg($im,null,60);
}