I tried something like this but it just makes the background of the image white, not necessarily the alpha of the image. I wanted to just upload everything as jpg's so if i could somehow "flatten" a png image with some transparently to default it to just be white so i can use it as a jpg instead. Appreciate any help. Thanks.
$old = imagecreatefrompng($upload); $background = imagecolorallocate($old,255,255,255); imagefill($old, 0, 0, $background); imagealphablending($old, false); imagesavealpha($old, true);
Open the image you want to convert into PNG by clicking File > Open. Navigate to your image and then click “Open.” Once the file is open, click File > Save As. In the next window make sure you have PNG selected from the drop-down list of formats, and then click “Save.”
Go to File > Save as and open the Save as type drop-down menu. You can then select JPEG and PNG, as well as TIFF, GIF, HEIC, and multiple bitmap formats. Save the file to your computer and it will convert.
<?php $input_file = "test.png"; $output_file = "test.jpg"; $input = imagecreatefrompng($input_file); $width = imagesx($input); $height = imagesy($input); $output = imagecreatetruecolor($width, $height); $white = imagecolorallocate($output, 255, 255, 255); imagefilledrectangle($output, 0, 0, $width, $height, $white); imagecopy($output, $input, 0, 0, 0, 0, $width, $height); imagejpeg($output, $output_file);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With