51 $amount = min($amount, 500) * 0.016;
52 $radius = abs(round(min(50, $radius) * 2));
53 $threshold = min(255, $threshold);
59 $imgCanvas = ImageCreateTrueColor($w, $h);
60 $imgBlur = ImageCreateTrueColor($w, $h);
70 if (function_exists(
'imageconvolution')) {
76 ImageCopy($imgBlur, $img, 0, 0, 0, 0, $w, $h);
77 ImageConvolution($imgBlur, $matrix, 16, 0);
83 for (
$i = 0;
$i < $radius;
$i++) {
84 ImageCopy( $imgBlur, $img, 0, 0, 1, 0, $w - 1, $h);
85 ImageCopyMerge($imgBlur, $img, 1, 0, 0, 0, $w , $h, 50);
86 ImageCopyMerge($imgBlur, $img, 0, 0, 0, 0, $w , $h, 50);
87 ImageCopy( $imgCanvas, $imgBlur, 0, 0, 0, 0, $w , $h);
88 ImageCopyMerge($imgBlur, $imgCanvas, 0, 0, 0, 1, $w , $h - 1, 33.33333);
89 ImageCopyMerge($imgBlur, $imgCanvas, 0, 1, 0, 0, $w , $h, 25);
96 for ($x = 0; $x < $w-1; $x++) {
97 for ($y = 0; $y < $h; $y++) {
99 $rgbOrig = ImageColorAt($img, $x, $y);
100 $rOrig = (($rgbOrig >> 16) & 0xFF);
101 $gOrig = (($rgbOrig >> 8) & 0xFF);
102 $bOrig = ($rgbOrig & 0xFF);
104 $rgbBlur = ImageColorAt($imgBlur, $x, $y);
106 $rBlur = (($rgbBlur >> 16) & 0xFF);
107 $gBlur = (($rgbBlur >> 8) & 0xFF);
108 $bBlur = ($rgbBlur & 0xFF);
112 $rNew = ((abs($rOrig - $rBlur) >= $threshold) ? max(0, min(255, ($amount * ($rOrig - $rBlur)) + $rOrig)) : $rOrig);
113 $gNew = ((abs($gOrig - $gBlur) >= $threshold) ? max(0, min(255, ($amount * ($gOrig - $gBlur)) + $gOrig)) : $gOrig);
114 $bNew = ((abs($bOrig - $bBlur) >= $threshold) ? max(0, min(255, ($amount * ($bOrig - $bBlur)) + $bOrig)) : $bOrig);
116 if (($rOrig != $rNew) || ($gOrig != $gNew) || ($bOrig != $bNew)) {
117 $pixCol = ImageColorAllocate($img, $rNew, $gNew, $bNew);
118 ImageSetPixel($img, $x, $y, $pixCol);
123 for ($x = 0; $x < $w; $x++) {
124 for ($y = 0; $y < $h; $y++) {
125 $rgbOrig = ImageColorAt($img, $x, $y);
126 $rOrig = (($rgbOrig >> 16) & 0xFF);
127 $gOrig = (($rgbOrig >> 8) & 0xFF);
128 $bOrig = ($rgbOrig & 0xFF);
130 $rgbBlur = ImageColorAt($imgBlur, $x, $y);
132 $rBlur = (($rgbBlur >> 16) & 0xFF);
133 $gBlur = (($rgbBlur >> 8) & 0xFF);
134 $bBlur = ($rgbBlur & 0xFF);
136 $rNew = min(255, max(0, ($amount * ($rOrig - $rBlur)) + $rOrig));
137 $gNew = min(255, max(0, ($amount * ($gOrig - $gBlur)) + $gOrig));
138 $bNew = min(255, max(0, ($amount * ($bOrig - $bBlur)) + $bOrig));
139 $rgbNew = ($rNew << 16) + ($gNew <<8) + $bNew;
140 ImageSetPixel($img, $x, $y, $rgbNew);
144 ImageDestroy($imgCanvas);
145 ImageDestroy($imgBlur);