How can I use ImageMagick (with the php extension) to set the transparent background to white when converting an image from PNG to JPEG?
If you are using the Imagick extension:
setImageBackgroundColor(new ImagickPixel('white'));
// flattens multiple layers
$i = $i->flattenImages();
// the output format
$i->setImageFormat('jpg');
// save to disk
$i->writeImage('image.jpg');
// and/or output directly
// header('Content-Type: '.$i->getFormat());
// echo $i->getImageBlob();
// cleanup
$i->clear();
$i->destroy();