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

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software