Linux 批量转换:使用 convert 更改 jpg 的质量但保留其名称
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9929652/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Linux batch conversion: Change quality of jpg with convert but keep its name
提问by Frank Vilea
If I convert my images with
如果我转换我的图像
convert -quality 80% *.jpg
It works, but the software changes the file names to the first one it picks. How can I keep the name or even replace the previous image with that of a lower quality.
它可以工作,但软件会将文件名更改为它选择的第一个。我怎样才能保留名称,甚至用质量较低的图像替换以前的图像。
采纳答案by Zsolt Botykai
Try this instead:
试试这个:
mogrify -quality 80% *.jpg
回答by ring bearer
convert command help:
转换命令帮助:
convert input-file [options] output-file
convert input-file [options] output-file
Now a little script to convert all jpg files to 80% quality of original under current directory
现在一个小脚本将所有 jpg 文件转换为当前目录下原始文件的 80% 质量
for file in *.jpg; do
convert "$file" -quality 80% "$file"
done;
回答by David Jung
This will work for you.
这对你有用。
convert -quality 80% '*.jpg' -set filename:original %t %[filename:original].jpg