> 16) & 0xFF; $g = ($pixel >> 8) & 0xFF; $b = $pixel & 0xFF; // new $newR += $r * $kernel[$ky][$kx]; $newG += $g * $kernel[$ky][$kx]; $newB += $b * $kernel[$ky][$kx]; } } $newR = \max(0, \min(255, $newR)); $newG = \max(0, \min(255, $newG)); $newB = \max(0, \min(255, $newB)); \imagesetpixel($im, $x, $y, (int) (($newR << 16) + ($newG << 8) | $newB)); } } } if (\strripos($outPath, 'png') !== false) { \imagepng($im, $outPath); } elseif (\strripos($outPath, 'jpg') !== false || \strripos($outPath, 'jpeg') !== false) { \imagejpeg($im, $outPath); } else { \imagegif($im, $outPath); } \imagedestroy($im); } }