英文:
Converting jpg, jpeg, png to webp in Linux Command Line
问题
在运行以下命令后:
$ sudo apr-get install webp
我运行了以下脚本:
$ for file in *.jpg *.jpeg *.png; do cwebp "$file" -o "${file%.*}.webp"; cp --preserve=mode "$file" "${file%.*}.webp"; done
当前目录中的所有文件都被转换为webp格式,然而,文件大小完全相同。就好像它实际上没有压缩文件,而只是改变了文件扩展名。
英文:
After running:
$ sudo apr-get install webp
I ran the following script:
$ for file in *.jpg *.jpeg *.png; do cwebp "$file" -o "${file%.*}.webp"; cp --preserve=mode "$file" "${file%.*}.webp"; done
All files within the current directory were converted to webp, however, the size was exactly the same. It was as if it didn't actually compress the file and instead just changed the ending.
答案1
得分: 0
为什么需要"cp"行?它只是从上一个命令中复制jpeg/png文件到webp文件,这就是为什么文件大小没有改变的原因。
英文:
cp --preserve=mode "$file" "${file%.*}.webp";
Why do you need the "cp" line? It's just copying the jpeg/png to the webp file from the previous command and that's why you're seeing no change in file size.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论