If you have a transparent background png the alpha channel will failing...bugfix:
class GDLuminanceSource ...
...
public function GDLuminanceSource($gdImage, $width, $height)
{
...
for ($j = 0; $j < $height; $j++) {
for ($i = 0; $i < $width; $i++) {
$argb = imagecolorat($this->$gdImage, $i, $j);
$pixel = imagecolorsforindex($this->$gdImage, $argb);
$r = $pixel['red'];
$g = $pixel['green'];
$b = $pixel['blue'];
$a = $pixel['alpha']; //0..127
if ( $a >= 63 ) {
$this->luminances[] = 255;
} else {
if ($r == $g && $g == $b) {
// Image is already greyscale, so pick any channel.
$this->luminances[] = $r;//(($r + 128) % 256) - 128;
} else {
// Calculate luminance cheaply, favoring green.
$this->luminances[] = ($r + 2 * $g + $b) / 4;//(((($r + 2 * $g + $b) / 4) + 128) % 256) - 128;
}
}
}
}
If you have a transparent background png the alpha channel will failing...bugfix:
class GDLuminanceSource ...
...
public function GDLuminanceSource($gdImage, $width, $height)
{
...
for ($j = 0; $j < $height; $j++) {
for ($i = 0; $i < $width; $i++) {
$argb = imagecolorat($this->$gdImage, $i, $j);
$pixel = imagecolorsforindex($this->$gdImage, $argb);
$r = $pixel['red'];
$g = $pixel['green'];
$b = $pixel['blue'];
$a = $pixel['alpha']; //0..127
if ( $a >= 63 ) {
$this->luminances[] = 255;
} else {
if ($r == $g && $g == $b) {
// Image is already greyscale, so pick any channel.
$this->luminances[] = $r;//(($r + 128) % 256) - 128;
} else {
// Calculate luminance cheaply, favoring green.
$this->luminances[] = ($r + 2 * $g + $b) / 4;//(((($r + 2 * $g + $b) / 4) + 128) % 256) - 128;
}
}
}
}