Guest User

Untitled

a guest
May 22nd, 2018
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.02 KB | None | 0 0
  1. <?
  2.    $img="telefone.jpg";
  3.    $img=imagecreatefromjpeg($img);
  4.    $w=imagesx($img);
  5.    $h=imagesy($img);
  6.  
  7.       $tmp_img = imagecreatetruecolor($w, $h);
  8.       for($x=0;$x<$w;$x++){
  9.          for($y=0;$y<$h;$y++){
  10.  
  11.             $rnd=rand(0,100);
  12.             $dx = cos($rnd/100*6.28)*5;
  13.             $dy = sin($rnd/100*6.28)/5;
  14.  
  15.             $m1 = getmid($img, $x+$dx, $y+$dy);
  16.             $m2 = getmid($img, $x-$dx, $y-$dy);
  17.  
  18.             $r = 255-abs($m1-$m2)*2;
  19.             $g = 255-abs($m1-$m2)*2;
  20.             $b = 255-abs($m1-$m2)*2;
  21.  
  22.             imageSetPixel($tmp_img, $x, $y, ($b << 16) + ($g << 8) + $r);
  23.          }
  24.       }
  25.  
  26.    header('Content-type: image/jpeg');
  27.    imagepng($tmp_img);
  28.  
  29.    function getmid($img, $x, $y){
  30.       $rgb = getpix($img, $x, $y);
  31.       return ($rgb[0]+$rgb[1]+$rgb[2])/3;
  32.    }
  33.  
  34.    function getpix($img, $x, $y){
  35.       $rgb = imagecolorat($img, $x, $y);
  36.       $b = ($rgb >> 16) & 0xFF;
  37.       $g = ($rgb >> 8) & 0xFF;
  38.       $r = $rgb & 0xFF;
  39.       return array($r,$g,$b);
  40.    }
  41.  
  42. ?>
Add Comment
Please, Sign In to add comment