Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- $img="telefone.jpg";
- $img=imagecreatefromjpeg($img);
- $w=imagesx($img);
- $h=imagesy($img);
- $tmp_img = imagecreatetruecolor($w, $h);
- for($x=0;$x<$w;$x++){
- for($y=0;$y<$h;$y++){
- $rnd=rand(0,100);
- $dx = cos($rnd/100*6.28)*5;
- $dy = sin($rnd/100*6.28)/5;
- $m1 = getmid($img, $x+$dx, $y+$dy);
- $m2 = getmid($img, $x-$dx, $y-$dy);
- $r = 255-abs($m1-$m2)*2;
- $g = 255-abs($m1-$m2)*2;
- $b = 255-abs($m1-$m2)*2;
- imageSetPixel($tmp_img, $x, $y, ($b << 16) + ($g << 8) + $r);
- }
- }
- header('Content-type: image/jpeg');
- imagepng($tmp_img);
- function getmid($img, $x, $y){
- $rgb = getpix($img, $x, $y);
- return ($rgb[0]+$rgb[1]+$rgb[2])/3;
- }
- function getpix($img, $x, $y){
- $rgb = imagecolorat($img, $x, $y);
- $b = ($rgb >> 16) & 0xFF;
- $g = ($rgb >> 8) & 0xFF;
- $r = $rgb & 0xFF;
- return array($r,$g,$b);
- }
- ?>
Add Comment
Please, Sign In to add comment