Guest User

Untitled

a guest
Aug 15th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. Blending colors GD - PHP
  2. $image = 'o1.png';
  3. $overlay = 'o2.png';
  4.  
  5. $background = imagecreatefrompng($image);
  6.  
  7. imagealphablending($background, true);
  8.  
  9. // Create overlay image
  10. $overlay = imagecreatefrompng($overlay);
  11.  
  12. // get size
  13. $size = getimagesize("o2.png");
  14. $L=$size[0];
  15. $H=$size[1];
  16.  
  17. for($j=0;$j<$H;$j++){
  18. for($i=0;$i<$L;$i++){
  19.  
  20. $rgb = imagecolorat($overlay, $i, $j);
  21.  
  22. $red = (isset($_GET['r']) ? $_GET['r'] : 0);
  23. $green = (isset($_GET['g']) ? $_GET['g'] : 0);
  24. $blue = (isset($_GET['b']) ? $_GET['b'] : 0);
  25.  
  26. $r = ($rgb >> 16) & 0xFF;
  27. $g = ($rgb >> 8) & 0xFF;
  28. $b = $rgb & 0xFF;
  29.  
  30. if(($r==255)&&($g==255)&&($b==0)) {
  31.  
  32. $color = imagecolorallocate($background, $red, $green, $blue);
  33. imagesetpixel($background, $i, $j, $color);
  34.  
  35. }
  36.  
  37. }
  38. }
  39.  
  40.  
  41. header("Content-type: image/png");
  42. header("Content-Disposition: filename=" . $image);
  43.  
  44. imagepng($background);
  45.  
  46. // Destroy the images
  47. imagedestroy($background);
  48. imagedestroy($overlay);
Add Comment
Please, Sign In to add comment