PHP Imagick black background gif transparency

If you want to put a white background instead of black background, add this piece of code :

$path_parts = pathinfo($file);
if ($path_parts[‘extension’]==’gif’)
{
$img = imagecreatefromgif($file);
$imgr = imagecreatetruecolor($neww, $newh);
$bgc = imagecolorallocate ($imgr, 255, 255, 255);
imagefilledrectangle ($imgr, 0, 0, $neww, $newh, $bgc);

imagecopyresampled($imgr, $img, 0, 0, 0, 0, $neww, $newh, $pixw, $pixh);
}

Leave a Reply

Your email address will not be published. Required fields are marked *