php - 无法使用 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
现在一切正常! 希望这对其他人有用。感谢马克和克里斯的帮助
解决方案
推荐阅读
- reactjs - 使用标记库 - TypeError: mapped.parse is not a function
- antlr - 基本表达式 Antlr4 语法
- android - 在 AIR for Android 应用程序中在哪里调试此崩溃?
- html - 如何为 flex-direction 列提供最大高度?
- sql - PL/SQL 块查找每个国家的供应商数量
- sql - 从 1 行 3 列制作 3 行 1 列
- node.js - 在使用实例创建索引时在类之间调用实例(打字稿)
- azure-devops - 运行声纳质量门状态的管道时出错
- java - 如何检查在Junit的私有方法中传递了哪个值?
- c# - 如何在 c# 项目中使用 c++ dll