Advertisement
MyZik

script.php

Jun 14th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.69 KB | None | 0 0
  1. <?php
  2. function getColor() {
  3. return mt_rand(0,255);
  4. }
  5.  
  6. function c1(&$c, $rand) {
  7.     if($c['red'] <= 30 && $c['green'] >= 230 && $c['blue'] >= 220){
  8.         $c['red'] = $rand[0];
  9.         $c['green'] = $rand[1];
  10.         $c['blue'] = $rand[2];
  11.     }
  12.  
  13.     if($c['red'] <= 30 && $c['green'] >= 230 && $c['blue'] <= 30){
  14.         $c['red'] = $rand[0] * 0.8;
  15.         $c['green'] = $rand[1] * 0.8;
  16.         $c['blue'] = $rand[2] * 0.8;
  17.     }
  18. }
  19.  
  20.  
  21. function c2(&$c, $rand) {
  22.     if($c['red'] >= 240 && $c['green'] >= 240 && $c['blue'] <= 10){
  23.         $c['red'] = $rand[0];
  24.         $c['green'] = $rand[1];
  25.         $c['blue'] = $rand[2];
  26.     }
  27.     if($c['red'] >= 240 && $c['green'] <= 10 && $c['blue'] <= 10){
  28.         $c['red'] = $rand[0] * 0.6;
  29.         $c['green'] = $rand[1] * 0.6;
  30.         $c['blue'] = $rand[2] * 0.6;
  31.     }
  32. }
  33.  
  34.  
  35. function c3(&$c, $rand) {
  36.     if ($c['red'] <= 30 && $c['green'] >= 230 && $c['blue'] >= 220) {
  37.         $c['red'] = $rand[0];
  38.         $c['green'] = $rand[1];
  39.         $c['blue'] = $rand[2];
  40.     }
  41.     if ($c['red'] <= 30 && $c['green'] >= 230 && $c['blue'] <= 30) {
  42.         $c['red'] = $rand[0] * 0.8;
  43.         $c['green'] = $rand[1] * 0.8;
  44.         $c['blue'] = $rand[2] * 0.8;
  45.     }
  46.     if ($c['red'] >= 240 && $c['green'] >= 240 && $c['blue'] <= 10) {
  47.         $c['red'] = $rand[0] * 0.6;
  48.         $c['green'] = $rand[1] * 0.6;
  49.         $c['blue'] = $rand[2] * 0.6;
  50.     }
  51.     if ($c['red'] >= 240 && $c['green'] <= 10 && $c['blue'] <= 10) {
  52.         $c['red'] = $rand[0] * 0.4;
  53.         $c['green'] = $rand[1] * 0.4;
  54.         $c['blue'] = $rand[2] * 0.4;
  55.     }
  56. }
  57.  
  58. $path='i/' . microtime(1).'.png';
  59.  
  60. $h = 388; $w = 344;
  61.  
  62. $canvas = imagecreatetruecolor($w,$h);
  63.  
  64. $randNum = mt_rand(1,4);
  65. $img_src = 'https://svinooohenzo.ru/script/img/soboken'.$randNum.'.jpg';
  66.  
  67. $image = imagecreatefromjpeg($img_src);
  68.  
  69. $rand1 = [getColor(), getColor(), getColor()];
  70. $rand2 = [getColor(), getColor(), getColor()];
  71.  
  72. $i=0;
  73.  
  74. for($y=0; $y<$h; $y++){
  75.     for($x=0; $x<$w; $x++){
  76.         if ($i%5 === 0){
  77.             $irand = mt_rand(0,2);
  78.             $rand1[$irand] = min($rand1[$irand] * 1.00011, 255);
  79.             $rand2[$irand] = min($rand2[$irand] * 1.00011, 255);
  80.         }
  81.  
  82.         $index = imagecolorat($image, $x,$y);
  83.         $data = imagecolorsforindex($image, $index);
  84.  
  85.         c1($data, $rand1);
  86.         c2($data, $rand2);
  87.         c3($data, $rand1);
  88.  
  89.         $color = imagecolorallocatealpha($canvas, $data['red'], $data['green'], $data['blue'], $data['alpha']);
  90.         imagesetpixel($canvas, $x,$y, $color);
  91.         $i++;
  92.     }
  93. }
  94.  
  95. header('Content-Type: image/png');
  96.  
  97. imagepng($canvas, $path, 9);
  98.  
  99. readfile($path);
  100.  
  101. imagedestroy($canvas);
  102. imagedestroy($image);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement