Solution to Black Transparent Background of php Scale gif and png Images
- 2021-07-21 07:55:21
- OfStack
In the work, I need to zoom some gif pictures and then go to Imagecopymerge, but I found that after using imagecreatetruecolor and imagecopyresampled, I found that the background picture was wrong, and the original transparent background picture turned black. Later, I found that I could make some modifications:
$img = imagecreatetruecolor(200, 200);
//2. Coloring
$color=imagecolorallocate($img,255,255,255);
//3. Setting Transparency
imagecolortransparent($img,$color);
imagefill($img,0,0,$color);
Then imagecopyresampled and Imagecopymerge will be no problem