I would like to know if is it possible to swipe a specific color with an Image.
I would use this if I wanted to change the color:
$imgname = "http://i.imgur.com/a94EGj9.png";
$im = imagecreatefrompng ($imgname);
imagetruecolortopalette($im,false, 255);
$index = imagecolorclosest ( $im, 21,194,37 ); // get color
imagecolorset($im,$index,255,255,255); // SET NEW COLOR
$time = time();
$imgname = "img".$time.".png";
imagegif($im, $imgname );
imagedestroy($im);
echo "<img src='".$imgname."' width='500' height='500' >";
But I want to change the background with an image.
Example, I downloaded a image of a room, and I painted the ground.
http://i.imgur.com/a94EGj9.png
I would like to know if I can remove the green ground and insert an image in there, like this:
http://i.imgur.com/sXWXkJ5.jpg
Is it possible to do that?
Thank you.
You probably want to use imagecopymerge, with 100 alpha.
$background_layer = imagecreatefrompng('image_background.png');
$imgname = "http://i.imgur.com/a94EGj9.png";
$im = imagecreatefrompng ($imgname);
$color = imagecolorallocate($im, 21, 194, 37);
imagecolortransparent($im, $color);
imagecopymerge($background_layer, $im, 0, 0, 0, 0, imagesx($im), imagesy($im), 100);
header("Content-Type: image/png");
imagepng($background_layer);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.