heif-converter
相信很多朋友都有过这样的经历:朋友用 iphone 拍了张照片发给你,结果你发现它是个
.heic
.avif
我之前也深陷这种困境。每次遇到 HEIC 文件,要么得去网上找个在线转换器,上传下载不仅耗时,还总担心图片隐私;要么就得安装一个大型的桌面应用,只为偶尔的转换需求。作为一名 PHP 开发者,我一直在寻找一个更优雅、更自动化的解决方案,最好能直接集成到我的开发流程中。
maestroerror/heif-converter
直到我发现了
maestroerror/heif-converter
heif-converter
go-libheif
libheif
那么,如何将它引入你的 PHP 项目,解决图片转换的燃眉之急呢?
通过 Composer 轻松安装
首先,你需要将
heif-converter
<pre class="brush:php;toolbar:false;">composer require maestroerror/heif-converter
Composer 会自动下载并安装
heif-converter
vendor
安装底层依赖 libheif
heif-converter
libheif
maestroerror/heif-converter
<pre class="brush:php;toolbar:false;">./vendor/maestroerror/heif-converter/install-libheif.sh
<pre class="brush:php;toolbar:false;">./vendor/maestroerror/heif-converter/install-libheif-macos.sh
<pre class="brush:php;toolbar:false;">.\vendor\maestroerror\heif-converter\install-libheif-windows.bat
运行对应平台的脚本,它会帮助你安装或配置
libheif
git
brew
git
使用 heif-converter
安装完成后,你可以在
vendor/bin
heif-converter
./vendor/bin/heif-converter-linux
./vendor/bin/heif-converter-windows.exe
./vendor/bin/heif-converter-macos
例如,要在 Linux 系统上将 HEIC 图片转换为 PNG,只需运行:
<pre class="brush:php;toolbar:false;">./vendor/bin/heif-converter-linux heic input.heic output.png
命令格式非常直观:
[可执行文件] [源格式] [输入文件] [输出文件]
heif-converter
libheif
实际应用场景:
shell_exec()
Symfony/Process
heif-converter
heif-converter
有了
maestroerror/heif-converter
以上就是如何解决HEIC/AVIF图片转换难题?使用Composer和heif-converter轻松搞定!的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号