首页 > 解决方案 > 无法使用 imagick 保存 webp 格式 - 已解决

问题描述

我正在开发一个面板,我在其中上传 jpg,复制它,调整大小,保存另一个 jpg,现在我还希望能够创建一个副本,但使用 webp 扩展。

我到处检查,找不到有同样问题的人。我在 CentOS cPanel 上运行 cPanel > 版本:ImageMagick 6.9.10-68 Q16 x86_64 2020-04-01

$imagick = new \Imagick($targetJpg); 
$imagick->writeImage('webp:'.$targetWebp);

我收到了这个错误

致命错误:未捕获的 ImagickException:委托失败 `'cwebp' -quiet %Q '%i' -o '%o'' @ error/delegate.c/InvokeDelegate/1928 in /...dirs.../pic-upload .php:108 堆栈跟踪:#0 /...dirs.../pic-upload.php(108): Imagick->writeimage('webp:../images/...') #1

==================================================== =======

在我的本地机器 OSX 中,使用 Mamp 解决了 @MarkSetchell 的帮助问题。

在 OSX > 终端类型:cwebp -version webp 1.1.0

类型:类型 cwebp cwebp 是散列的 (/usr/local/bin/cwebp)

标记解决方案> 工作!:) 在 macOS 上,您的 cwebp 似乎是 /usr/local/bin 中的自制程序,所以我建议您找到名为 delegates.xml 的 Imagick 配置文件并对其进行编辑,使其显示“cwebp”-quiet -q %Q '%I'... 变成 '/usr/local/bin/cwebp' -quiet -q...

==================================================== =======

在 CentOS cPanel 中

既没有安装 cwebp 也没有安装 dwebp。这是由于未安装软件包 libwebp-tools。

我安装了它们并检查了结果: [root@server:/]$ whereis cwebp cwebp: /usr/bin/cwebp /usr/share/man/man1/cwebp.1.gz [root@server:/]$ whereis dwebp dwebp:/usr/bin/dwebp /usr/share/man/man1/dwebp.1.gz

现在一切正常! 希望这对其他人有用。感谢马克和克里斯的帮助

标签: phpjpegimagickwebp

解决方案


推荐阅读