PHP添加图片到另一个 [英] php add a picture onto another

查看:98
本文介绍了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);
?>

此处有更多信息.

这篇关于PHP添加图片到另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆