将 jpg、jpeg、png 转换为 webp 在 Linux 命令行中

huangapple go评论82阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年7月14日 06:15:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/76683576.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定