Home >Backend Development >PHP Tutorial >Solution to PHP scaling GIF and PNG images with transparent background turning into black_PHP Tutorial
I need to scale some gif images at work and then go to Imagecopymerge, but I found out after using imagecreatetruecolor and imagecopyresampled The background image is wrong. The originally transparent background image turned into black. Later I found that some modifications can be done:
3 45 |
$img = imagecreatetruecolor(200, 200);
//2. Coloring
$color=imagecolorallocate($img,255,255,255);
//3. Set transparency
imagecolortransparent($img,$color);
imagefill($img,0,0,$color);
|