When saving an alpha blended image like this:
using imagejpeg(), with the code below, I get a black background.
$sourcePath = "<path to the image above>";
$destPath = "<path to where I want to store it>";
$image = imagecreatefrompng($sourcePath);
imagejpeg($image, $destPath, 85);
I end up with a black square. That's clearly not what I need, the background should be white.
I read up on alpha blending, tried several things with the GD functions in PHP, but I couldn't get it done. Perhaps I should copy the image to a new image before saving it, but I'd rather not do that.
My question is: What is the simplest way to save the above image with the proper white background using the PHP GD functions? No alpha blending is needed in output, all I want is a white background.
Bonus question: Is there a way to detect whether an image has an alpha channel?