我想从命令行用jpg图像优化整个测试文件夹。我找到了这个,但它不起作用:
cd /home/site/html/update/test/
find . -exec jpegtran -optimize "{}" "{}.opti.jpg" "{}" \;我想要覆盖现有的图像。
有什么建议吗?
答案:
find /img/path -name "*.jpg" -type f -exec jpegtran -copy none -optimize -outfile {} {} \; 发布于 2017-07-19 09:03:55
答案:
find /img/path -name "*.jpg" -type f -exec jpegtran -copy none -optimize -outfile {} {} \;发布于 2021-10-21 08:00:25
虽然它在这里很早就解决了,但是谈到了Python方法:
import subprocess
for image_name in arr:
subprocess.call(["jpegtran", "-your", "-instructions"])假设你的指令是这样的:
jpegtran -optimize -progressive -scans script_new.txt -outfile progressive.jpg original.jpg
所以你的指令应该是这样的:
subprocess.call(["jpegtran", "-optimize", "-progressive", "-scans", f"{scan_name}.txt", "-outfile", name_progressive, name_original])为方便起见,我们使用了name_progressive、name_original和scan_name作为变量,并使用了f-string概念。
https://stackoverflow.com/questions/15835351
复制相似问题