Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Blending colors GD - PHP
- $image = 'o1.png';
- $overlay = 'o2.png';
- $background = imagecreatefrompng($image);
- imagealphablending($background, true);
- // Create overlay image
- $overlay = imagecreatefrompng($overlay);
- // get size
- $size = getimagesize("o2.png");
- $L=$size[0];
- $H=$size[1];
- for($j=0;$j<$H;$j++){
- for($i=0;$i<$L;$i++){
- $rgb = imagecolorat($overlay, $i, $j);
- $red = (isset($_GET['r']) ? $_GET['r'] : 0);
- $green = (isset($_GET['g']) ? $_GET['g'] : 0);
- $blue = (isset($_GET['b']) ? $_GET['b'] : 0);
- $r = ($rgb >> 16) & 0xFF;
- $g = ($rgb >> 8) & 0xFF;
- $b = $rgb & 0xFF;
- if(($r==255)&&($g==255)&&($b==0)) {
- $color = imagecolorallocate($background, $red, $green, $blue);
- imagesetpixel($background, $i, $j, $color);
- }
- }
- }
- header("Content-type: image/png");
- header("Content-Disposition: filename=" . $image);
- imagepng($background);
- // Destroy the images
- imagedestroy($background);
- imagedestroy($overlay);
Add Comment
Please, Sign In to add comment