Sorry, but I tried your exact same methodology to grayscale the image, but instead I got a timeout error followed by a chopped up color piece of an image instead.
I coped your code:
global $section;
for ($i = 0; $i <= 255; $i++) $colorNDX[$i] = @imagecolorallocate($this->newImage, $i, $i, $i);
/*if (is_array($colorNDX) && @sizeof($colorNDX) > 0) {
for ($y = 0; $y < $this->{$section . '_height'}; $y++) {
for ($x = 0; $x < $this->{$section . '_width'}; $x++) {
$ndx = @imagecolorat($this->image, $x, $y);
$ndxColorArray = @imagecolorsforindex($this->image, $ndx);
$avg = floor(($ndxColorArray['red'] + $ndxColorArray['green'] + $ndxColorArray['blue']) / 3);
@imagesetpixel($this->newImage, $x, $y, $colorNDX[$avg]);
}
}
}
*/
@imagecopy($this->newImage, $this->$section, 0, 0, 0, 0,
$this->{$section . '_width'}, $this->{$section . '_height'});
Taking out the @ warning suppressors makes no difference, no errors, warnings, no nothing, just mangled color images instead of mangled grayscale images (w/ segfault), so sorry it looks like it works worse than the loopy code I had 🙁