php缩放gif和png图透明背景变成黑色的解决方法,缩放png
工作中需要缩放一些gif图然后在去Imagecopymerge,可是发现使用了imagecreatetruecolor和imagecopyresampled后发现背景图不对,本来透明的背景图变成了黑色,后来发现做一些修改才可以:
$img = imagecreatetruecolor(200, 200); //2.上色 $color=imagecolorallocate($img,255,255,255); //3.设置透明 imagecolortransparent($img,$color); imagefill($img,0,0,$color);
然后再进行imagecopyresampled和Imagecopymerge就没有问题了
效果图标显示的呢就是成功以后的图标。所以你这显示的不是透明的。按确定也不会变成透明。你需要重新处理一下。 嗯,我想说,并不是你把图片的格式换了就没有底图了。而是要把底图抠掉,换成透明图片格式,这样才是透明的图片。 如果你不会,你可以把图片放上来,我可以帮你去掉
那要看你怎么转换的,是直接重命名就不行,得用PS或者U5之类的软件另存。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

Dreamweaver Mac version
Visual web development tools

SublimeText3 Chinese version
Chinese version, very easy to use

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 English version
Recommended: Win version, supports code prompts!
