Php add a picture to another

I would like to change the color of the image using php. if I wanted to make it more red, then the image at a higher level in the image with transparent red and more or less high can indicate how the original photo should be red. Can I tell gd php functions to create a color image (RGBA) and apply it to another image? thanks:)

0
source share
1 answer

You can try using the GD function imagecopymerge, which copies one image to another and supports alpha transparency. Something like this should work:

<?php $redimg = imagecreatetruecolor(100, 100); $image = imagecreatefrompng('image.png'); // sets background to red $red = imagecolorallocate($redimg, 255, 0, 0); imagefill($redimg, 0, 0, $red); // Merge the red image onto the PNG image imagecopymerge($image, $redimg, 0, 0, 0, 0, 100, 100, 75); header('Content-type: image/png'); imagepng($image); imagedestroy($image); imagedestroy($redimg); ?> 

More information here .

+2
source

Source: https://habr.com/ru/post/1493202/


All Articles