array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.imagecreatefromwebp.php', 1 => 'imagecreatefromwebp', ), 'up' => array ( 0 => 'ref.image.php', 1 => 'GD 和图像处理 函数', ), 'prev' => array ( 0 => 'function.imagecreatefromwbmp.php', 1 => 'imagecreatefromwbmp', ), 'next' => array ( 0 => 'function.imagecreatefromxbm.php', 1 => 'imagecreatefromxbm', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/image/functions/imagecreatefromwebp.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5 >= 5.4.0, PHP 7, PHP 8)
imagecreatefromwebp — 由文件或 URL 创建一个新图象。
imagecreatefromwebp() 返回图像标识符,代表从指定文件名获得的图像。请注意,无法读取动画 WebP 文件。
如已启用fopen 包装器,在此函数中, URL 可作为文件名。关于如何指定文件名详见 fopen()。各种 wapper 的不同功能请参见 支持的协议和封装协议,注意其用法及其可提供的预定义变量。
filename
WebP 图像路径。
成功后返回图象对象,失败后返回 false
。
示例 #1 使用 imagecreatefromwebp() 转换 WebP 图像为 jpeg 图像
<?php
// 加载 WebP 文件
$im = imagecreatefromwebp('./example.webp');
// 以 100% 的质量转换成 jpeg 格式
imagejpeg($im, './example.jpeg', 100);
imagedestroy($im);
?>