Home >Backend Development >PHP Tutorial >How to solve the problem when the transparent background of php zooms gif and png images turns into black, zoom png_PHP tutorial

How to solve the problem when the transparent background of php zooms gif and png images turns into black, zoom png_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:17:141349browse

Solution to how to make the transparent background of php zoom gif and png images turn black, zoom png

At work, I need to scale some gifs and then go to Imagecopymerge, but I found that after using imagecreatetruecolor and imagecopyresampled, I found that the background image was wrong. The original transparent background image turned into black. Later I found that I had to make some modifications:

 $img = imagecreatetruecolor(200, 200); 
//2.上色 
$color=imagecolorallocate($img,255,255,255); 
//3.设置透明 
imagecolortransparent($img,$color); 
imagefill($img,0,0,$color); 

Then imagecopyresampled and Imagecopymerge will be no problem

The transparent ring in Xuanwu is in GIF format, right? Why did I use Meitu Xiuxiu to convert PNG to GIF? The background effect picture is black and it will be transparent after finishing it

The effect icon displays the icon after success. So what you display is not transparent. It will not become transparent even if you press OK. You need to reprocess it. Well, I want to say that it’s not that if you change the format of the image, there will be no base map. Instead, you need to cut out the base image and replace it with a transparent image format, so that it is a transparent image. If you don’t know how, you can post the picture and I can remove it for you

Why does the background color become opaque after converting PNG format images to GIF?

It depends on how you convert it. Direct renaming will not work. You have to use software such as PS or U5 to save it.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/894135.htmlTechArticleSolution to how to make the transparent background of php zoom gif and png images turn black, zoom png needs to zoom some gif images at work Then I went to Imagecopymerge, but found that imagecreatetruecolor and i were used...
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