图像压缩工具通过命令行 [英] Image Compression tools via command line
问题描述
我正在寻找通过命令行压缩图像(png和jpeg)的最佳工具。
谷歌搜索后我发现 trimage 这很好,因为它压缩了png和jepeg ,但在这种情况下压缩比非常差。
I'm searching best tool to compress images (png and jpeg) via command line.
After googling I found trimage which is good as it compresses both png and jepeg, but compression ratio is very poor in this case.
我遇到了 jpeg-optimizer.com 在线工具,它比trimage做得更好。任何人都可以帮助找到合适的工具。
I came across jpeg-optimizer.com online tool which does the job way better than trimage. Can any one help to find the right tool for this.
推荐答案
我正在使用以下工具执行无损图像压缩:
I'm using the following tools to perform lossless image compression:
pngcrush
gifsicle
jpegtran
对于每个程序,我创建了两个快捷方式:
For each of the programs, I've created two shortcuts:
- 执行实际压缩并显示两个文件的文件大小的文件
- 替换的文件带有压缩文件的原始文件(如果我满意的话,我会做上箭头,前面的命令前缀为m,然后按回车键。)
我把它放在我的 .bashrc
中:
# Image optimization tools
png() {
pngcrush -brute "$1"{,.} && du -b "$1"{,.}
}
gif() {
gifsicle -O "$1" -o "$1." && du -b "$1"{,.}
}
jpeg() {
jpegtran "$1" > "$1." && du -b "$1"{,.}
}
# Just for easy access in history
mpng() {
mv "$1"{.,}
}
mgif() {
newsize=$(wc -c <"$1.")
oldsize=$(wc -c <"$1")
if [ $oldsize -gt $newsize ] ; then
mv "$1"{.,}
else
rm "$1."
fi
}
mjpeg() {
mv "$1"{.,}
}
注意: pngcrush -brute
非常详细。如果您对进度不感兴趣,请将输出重定向到 / dev / null
。
Note: pngcrush -brute
is very verbose. Redirect the output to /dev/null
if you're not interested in the progress.
这篇关于图像压缩工具通过命令行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!