具有透明背景的PHP imagecopy [英] PHP imagecopy with transparent background

查看:335
本文介绍了具有透明背景的PHP imagecopy的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用此代码从另一个png图像创建一个图像,默认情况下背景为黑色.我的问题是如何设置透明背景?

I use this code to create an image from another png image, the background is black by default. My question is how to set a transparent background?

$input = imagecreatefrompng('image.png');
$output = imagecreatetruecolor(50, 50);

imagecopy($output, $input, 4,0, 8,8, 8,8);
imagecopy... etc.

header('Content-Type: image/png');
imagepng($output);

有没有简单的方法可以做到这一点?谢谢

Is there a easy way of doing this? Thanks

推荐答案

设置给定图像中的透明颜色.

Sets the transparent color in the given image.

int imagecolortransparent ( resource $image [, int $color ] )

这是链接

这篇关于具有透明背景的PHP imagecopy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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