为什么上传图片中含有透明通道,图片就会变成黑色? php图片上传 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 上传不会改变图片,你可以把图片贴在这里对于 GD2 缩略图都应 imagecreatetruecolor、imagecopyresampled如果有透明色,还需 imagecolortransparent imagecreate 和 imagecreatetruecolor 产生的图片都是黑色的(注意:不是透明的)你的图片是透明的,自然就将背景显现出来了也就是说图片是放在黑色的背景上的了所以被缩放的图片还需要设置透明色$url = 'http://img.bbs.csdn.net/upload/201404/15/1397545309_839045.gif';$sm = imagecreatefromstring(file_get_contents($url));$dm = imagecreatetruecolor(imagesx($sm), imagesy($sm));//$dm = imagecreate(imagesx($sm), imagesy($sm));$c = imagecolorallocate($dm, 100, 1, 1);imagefill($dm, 0, 0, $c);imagecolortransparent($dm, $c);imagecopyresampled($dm, $sm, 0, 0, 0, 0, imagesx($dm), imagesy($dm), imagesx($sm), imagesy($sm));imagegif($dm); 我自己解决了。。还是谢谢你们,是我没有用imagefill事先填充的原因 查询连续天数的实现 高手!求解!! 大家帮我看看查询语句这样写会报错为什么??? php配置问题 html或者php能否用代码实现网页的简繁体转换 在遍历结果集中判断两次循环的值是否都为0 面试问题 PHP按钮返回404错误 php里怎么能将html代码转成word xml格式的代码 php代码麻烦帮忙解释下用C#代码实现 非经营性网站未备案月底暂时关闭 7月10日前仍可补办 SESSION值的问题!
对于 GD2 缩略图都应 imagecreatetruecolor、imagecopyresampled
如果有透明色,还需 imagecolortransparent
你的图片是透明的,自然就将背景显现出来了
也就是说图片是放在黑色的背景上的了
所以被缩放的图片还需要设置透明色$url = 'http://img.bbs.csdn.net/upload/201404/15/1397545309_839045.gif';
$sm = imagecreatefromstring(file_get_contents($url));
$dm = imagecreatetruecolor(imagesx($sm), imagesy($sm));
//$dm = imagecreate(imagesx($sm), imagesy($sm));
$c = imagecolorallocate($dm, 100, 1, 1);
imagefill($dm, 0, 0, $c);
imagecolortransparent($dm, $c);
imagecopyresampled($dm, $sm, 0, 0, 0, 0, imagesx($dm), imagesy($dm), imagesx($sm), imagesy($sm));
imagegif($dm);