有人可以清楚地解释一下如何使用“pngcrush”吗?对于多个项目
我有一堆数百张图片,我想使用 pngcrush 来减小文件大小。
我知道如何用终端粉碎一个文件,但在网上我找到了一些假设先前知识的解释。
有人可以清楚地解释一下如何做吗?
谢谢 沙尼
I have a stack of hundreds of pictures and i want to use pngcrush for reducing the file sizes.
I know how to crush one file with terminal, but all over the web i find parts of explanations that assume previous knowledge.
can someone please explain how to do it clearly.
Thanks
Shani
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以使用以下脚本:
You can use following script:
当前版本的 pngcrush 支持开箱即用的此功能。
(我使用的是 pngcrush 1.7.81)
pngcrush -dir outputFolder inputFolder/*.png
将创建“outputFolder”(如果它不存在),并处理“inputFolder”中的所有 .png 文件,将它们放入“输出文件夹”。
显然,您可以添加其他选项,例如
pngcrush -dir outputFolder -reduce -brute -l9 inputFolder/*.png
Current versions of pngcrush support this functionality out of the box.
( I am using pngcrush 1.7.81)
pngcrush -dir outputFolder inputFolder/*.png
will create "outputFolder" if it does not exist and process all the .png files in the "inputFolder" placing them in "outputFolder".
Obviously you can add other options e.g.
pngcrush -dir outputFolder -reduce -brute -l9 inputFolder/*.png
到了 2023 年,有更好的工具来优化 png 图像,例如 OptiPNG
可选地使用命令 -o 定义质量,可以从 1 到 7,其中 7 是图像的最大压缩级别。
Being in 2023, there are better tools to optimize png images like OptiPNG
optionally the command -o defines the quality, being possible from 1 to 7, where 7 is the maximum compression level of the image.
高评级的修复对我来说似乎很危险;它开始压缩我的 iMac 中的所有 png 文件; need 是限制在指定目录的命令;我不是 UNIX 专家;我通过搜索所有以
.pngcrushed
结尾的文件并删除它们来撤消新文件The high rated fix appears dangerous to me; it started compressing all png files in my iMac; needed is a command restricted to a specified directory; I am no UNIX expert; I undid the new files by searching for all files ending in
.pngcrushed
and deleting them