We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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; } } } }
The text was updated successfully, but these errors were encountered:
Please somebody test it... class IMagickLuminanceSource ... public function _IMagickLuminanceSource(\Imagick $image, $width, $height) { ... $map = 'RGBA'; $mapLen = strlen($map); // $image->newPseudoImage(0, 0, "magick:rose"); //$pixels = $image->exportImagePixels(1, 1, $width, $height, "RGB", \Imagick::PIXEL_CHAR); $pixels = $image->exportImagePixels(1, 1, $width, $height, $map, \Imagick::PIXEL_CHAR);
$array = []; $rgb = []; $countPixels = count($pixels); for ($i = 0; $i < $countPixels; $i += $mapLen) { $r = $pixels[$i] & 0xff; $g = $pixels[$i + 1] & 0xff; $b = $pixels[$i + 2] & 0xff; $a = $pixels[$i + 3] & 0xff; //0: transparent 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; } } }
Sorry, something went wrong.
No branches or pull requests
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;
}
}
}
}
The text was updated successfully, but these errors were encountered: