工作中需要缩放一些gif图然后在去Imagecopymerge,可是发现使用了imagecreatetruecolor和imagecopyresampled后发现背景图不对,本来透明的背景图变成了黑色,后来发现做一些修改才可以:
1 | $img = imagecreatetruecolor(200, 200); |
2 | //2.上色 |
3 | $color =imagecolorallocate( $img ,255,255,255); |
4 | //3.设置透明 |
5 | imagecolortransparent( $img , $color ); |
6 | imagefill( $img ,0,0, $color ); |
然后再进行imagecopyresampled和Imagecopymerge就没有问题了