When saving a PNG as JPEG by using $im->setimageformat('jpeg'), the resulting saved image has the transparent background replaced with a black background.
Is there any way to change the colour of this background?
Tried a lot of functions to no avail, setimagebackground(), setimagemattecolor().. Hope someone can help me
PNG to JPEG, transparent background converts to black
Re: PNG to JPEG, transparent background converts to black
Nevermind, got it.
Code: Select all
$im->PaintOpaqueImage ('black', 'white', 50);
Re: PNG to JPEG, transparent background converts to black
Another method was to put the PNG image data on top of a new, blank, white $im object:
Code: Select all
$im2 = new imagick();
$im2->newImage($im->getImageWidth(),$im->getImageheight(),'white','jpeg');
$im2->compositeimage($im,imagick::COMPOSITE_DEFAULT,0,0);