I have tried to convert binary data into an image format and then save this image in a folder. I am using imagesavealpha
function but it is not working.
My code is below:
<?php
$image_data=file_get_contents('Logo.png');
$encoded_image=base64_encode($image_data);
$decoded_image=base64_decode($encoded_image);
$im = imagecreatefromstring($decoded_image);
header('Content-Type: image/png');
imagepng($im);
$fileName ='/image/'.date('ymdhis').'.png';
imagealphablending($im,false);
imagesavealpha($im, true);
?>
$data = base64_decode($data);
file_put_contents('/tmp/image.png', $data);
or
file_put_contents('img.png', base64_decode($base64string));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.