00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 class filters
00030 {
00031
00032 function noise (&$image, $runs = 30)
00033 {
00034
00035 $w = imagesx($image);
00036 $h = imagesy($image);
00037
00038 for ($n = 0; $n < $runs; $n++)
00039 {
00040
00041 for ($i = 1; $i <= $h; $i++)
00042 {
00043
00044 $randcolor = imagecolorallocate($image,
00045 mt_rand(0, 255),
00046 mt_rand(0, 255),
00047 mt_rand(0, 255));
00048
00049 imagesetpixel($image,
00050 mt_rand(1, $w),
00051 mt_rand(1, $h),
00052 $randcolor);
00053
00054 }
00055
00056 }
00057
00058 }
00059
00060 function signs (&$image, $font, $cells = 3)
00061 {
00062
00063 $w = imagesx($image);
00064 $h = imagesy($image);
00065
00066 for ($i = 0; $i < $cells; $i++)
00067 {
00068
00069 $centerX = mt_rand(1, $w);
00070 $centerY = mt_rand(1, $h);
00071 $amount = mt_rand(1, 15);
00072 $stringcolor = imagecolorallocate($image, 175, 175, 175);
00073
00074 for ($n = 0; $n < $amount; $n++)
00075 {
00076
00077 $signs = range('A', 'Z');
00078 $sign = $signs[mt_rand(0, count($signs) - 1)];
00079
00080 imagettftext($image, 25,
00081 mt_rand(-15, 15),
00082 $centerX + mt_rand(-50, 50),
00083 $centerY + mt_rand(-50, 50),
00084 $stringcolor, $font, $sign);
00085
00086 }
00087
00088 }
00089
00090 }
00091
00092 function blur (&$image, $radius = 3)
00093 {
00094
00095 $radius = round(max(0, min($radius, 50)) * 2);
00096
00097 $w = imagesx($image);
00098 $h = imagesy($image);
00099
00100 $imgBlur = imagecreate($w, $h);
00101
00102 for ($i = 0; $i < $radius; $i++)
00103 {
00104
00105 imagecopy ($imgBlur, $image, 0, 0, 1, 1, $w - 1, $h - 1);
00106 imagecopymerge($imgBlur, $image, 1, 1, 0, 0, $w, $h, 50.0000);
00107 imagecopymerge($imgBlur, $image, 0, 1, 1, 0, $w - 1, $h, 33.3333);
00108 imagecopymerge($imgBlur, $image, 1, 0, 0, 1, $w, $h - 1, 25.0000);
00109 imagecopymerge($imgBlur, $image, 0, 0, 1, 0, $w - 1, $h, 33.3333);
00110 imagecopymerge($imgBlur, $image, 1, 0, 0, 0, $w, $h, 25.0000);
00111 imagecopymerge($imgBlur, $image, 0, 0, 0, 1, $w, $h - 1, 20.0000);
00112 imagecopymerge($imgBlur, $image, 0, 1, 0, 0, $w, $h, 16.6667);
00113 imagecopymerge($imgBlur, $image, 0, 0, 0, 0, $w, $h, 50.0000);
00114 imagecopy ($image , $imgBlur, 0, 0, 0, 0, $w, $h);
00115
00116 }
00117
00118 imagedestroy($imgBlur);
00119
00120 }
00121
00122 }
00123