xxxxxxxxxx
PNG To WEBP Converter:
https://freetoolssite.com/tools/png-to-webp-converter
xxxxxxxxxx
function hs_webp2png($source_file, $destination_file, $compression_quality = 100)
{
$image = imagecreatefromwebp($source_file);
$result = imagepng($image, $destination_file, $compression_quality);
if (false === $result) {
return false;
}
imagedestroy($image);
return $destination_file;
}
xxxxxxxxxx
function hs_png2webp($source_file, $destination_file, $compression_quality = 100)
{
$image = imagecreatefrompng($source_file);
imagepalettetotruecolor($image);
imagealphablending($image, true);
imagesavealpha($image, true);
$result = imagewebp($image, $destination_file, $compression_quality);
if (false === $result) {
return false;
}
imagedestroy($image);
return $destination_file;
}