search
Homephp教程php手册php缩放gif和png图透明背景变成黑色的解决方法,缩放png

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就没有问题了

炫舞里透明戒子是GIF格式的吧为何我用美图秀秀把PNG转成GIF背景效果图是黑色的弄好了会透明

效果图标显示的呢就是成功以后的图标。所以你这显示的不是透明的。按确定也不会变成透明。你需要重新处理一下。 嗯,我想说,并不是你把图片的格式换了就没有底图了。而是要把底图抠掉,换成透明图片格式,这样才是透明的图片。 如果你不会,你可以把图片放上来,我可以帮你去掉
 

为何PNG格式图片转换成GIF后背景颜色变成不透明了

那要看你怎么转换的,是直接重命名就不行,得用PS或者U5之类的软件另存。
 

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Safe Exam Browser

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

SublimeText3 English version

Recommended: Win version, supports code prompts!