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 .
source share