我有一个 ios 和 android 应用程序。有时用户将 webP 图像上传到我的服务器。问题是当它从我的服务器下载时,ios 无法显示此图像。
所以我想检查我的 php 代码。如果图片是 webP 格式。然后我会将其转换为 png 格式。
我怎么能用 php 做到这一点?
最佳答案
为时已晚,但只是为了它。它只能使用 PHP 来完成。无需任何外部工具。
引自 PHP.net documentation :
<?php
// Load the WebP file
$im = imagecreatefromwebp('./example.webp');
// Convert it to a jpeg file with 100% quality
imagejpeg($im, './example.jpeg', 100);
imagedestroy($im);
?>
所以我假设你可以使用
imagepng()
而不是示例中的 imagejpeg。
关于php - 如何将 webP 图片格式转换为普通格式? php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31132343/