I have an image.png with white background and some trasparceny over it.
I tried this to convert the image into jpg:
$data = file_get_contents('image.png'); $resource = imagecreatefromstring($data); imagejpeg($resource); //> I TRIED WITH QUALITY = 100 TOO
Problem is where the png got the trasparency now the jpg got a pretty huge black zone. This is how jpg looks:
Any way to solve the problem?
As suggested by Abiusx I tried this too:
$data = file_get_contents('image.png'); $resource = imagecreatefromstring($data); imagealphablending($data, false); imagesavealpha($data, true); imagejpeg($resource);
But the result was the same. Please note The source .png image is:
Thanks to Patrick comment: here the trick: GD! Converting a png image to jpeg and making the alpha by default white and not black