doujiu9172 2015-12-08 03:49
浏览 54

将透明图像放置到另一个非透明图像

How can I place a transparent image to a background image using PHP?

I have here my code:

$width = 400;
$height = 400;

$base_image = imagecreatefrompng("img/frame1.png");
$top_image = imagecreatefrompng("randyorton.png");
$merged_image = "merged.png";

imagealphablending($base_image, true);
imagesavealpha($base_image, true);
imagealphablending($top_image, true);
imagesavealpha($top_image, true);


imagecopy($base_image, $top_image, 10080, 10080, 0, 0, $width, $height);
imagecopy($base_image, $top_image, 80, 80, 0, 0, $width, $height);
header('Content-Type: image/png');
imagepng($base_image, $merged_image);

What's wrong with this? The image I am creating now has a black background on it.

Please see this picture for reference:

enter image description here

Am I making sense?

Thanks!

  • 写回答

1条回答 默认 最新

  • doumisha5081 2015-12-08 06:21
    关注

    I get it. I have a big width and height for the top image. I just get the size of the top image and pass it on the imagecopy function. :D

    评论

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向