PHP添加图片到另一个
问题描述:
我想用php更改图像的颜色. 如果我想使其显得更红,则在透明红色和或多或少高的图像上的较高级别的图像可以指示原始照片应为红色. 我可以说gd php函数创建颜色(RGBA)的图像并将其应用于其他图像吗? 谢谢:)
I would like to change the color of an image with php. if I wanted to make it appear redder applicherei an image on a higher level across an image with a transparent red and more or less high can indicate how the original photo should be red. I can say gd php functions to create an image of a color (RGBA) and apply it to another image? thanks :)
答
您可以尝试使用GD的imagecopymerge函数,该函数将一个图像复制到另一个图像并支持alpha透明度.这样的事情应该起作用:
You can try using GD's imagecopymerge function, 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);
?>
此处有更多信息.