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
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 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
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.