有人可以清楚地解释一下如何使用“pngcrush”吗?对于多个项目

发布于 2024-11-16 18:03:03 字数 122 浏览 1 评论 0原文

我有一堆数百张图片,我想使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

暮年 2024-11-23 18:03:03

您可以使用以下脚本:

#!/bin/bash

# uncomment following line for more aggressive but longer compression
# pngcrush_options=-reduce -brute -l9
find . -name '*.png' -print | while read f; do
  pngcrush $pngcrush_options -e '.pngcrushed' "$f"
  mv "$f" "${f/%.pngcrushed/}"
done

You can use following script:

#!/bin/bash

# uncomment following line for more aggressive but longer compression
# pngcrush_options=-reduce -brute -l9
find . -name '*.png' -print | while read f; do
  pngcrush $pngcrush_options -e '.pngcrushed' "$f"
  mv "$f" "${f/%.pngcrushed/}"
done
梦一生花开无言 2024-11-23 18:03:03

当前版本的 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

柠栀 2024-11-23 18:03:03

到了 2023 年,有更好的工具来优化 png 图像,例如 OptiPNG

    • 安装
sudo apt-get install optipng
    • 用于一张图片
optipng imagen.png
    • 用于文件夹中的所有图片
find /path/to/files/ -name '*.png' -exec optipng -o7 {} \;

可选地使用命令 -o 定义质量,可以从 1 到 7,其中 7 是图像的最大压缩级别。

-o7

Being in 2023, there are better tools to optimize png images like OptiPNG

    • install
sudo apt-get install optipng
    • use for one picture
optipng imagen.png
    • use for all pictures in folder
find /path/to/files/ -name '*.png' -exec optipng -o7 {} \;

optionally the command -o defines the quality, being possible from 1 to 7, where 7 is the maximum compression level of the image.

-o7
姐不稀罕 2024-11-23 18:03:03

高评级的修复对我来说似乎很危险;它开始压缩我的 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文