xxxxxxxxxx
y'all think i should make an extension that automatically converts webp files to png files in the context menu?
xxxxxxxxxx
Maybe the first result, but this is the best one (source added too!):
cloudconvert.com/webp-to-png
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;
}