How To Convert PNG To JPG Image Format In PHP With Example?

How To Convert PNG To JPG Image Format In PHP With Example?

function yttags_png2jpg($source, $destination, $quality = 100)
{
    $image = imagecreatefrompng($source);
    $bg = imagecreatetruecolor(imagesx($image), imagesy($image));
    imagefill($bg, 0, 0, imagecolorallocate($bg, 255, 255, 255));
    imagealphablending($bg, true);
    imagecopy($bg, $image, 0, 0, 0, 0, imagesx($image), imagesy($image));
    imagedestroy($image);
    imagejpeg($bg, $destination, $quality);
    imagedestroy($bg);
}
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments