Jacob
Jacob

Reputation: 273

Converting jpg, jpeg, png to webp in Linux Command Line

After running:

$ sudo apt-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.

Upvotes: 2

Views: 3237

Answers (1)

hikerjobs
hikerjobs

Reputation: 386

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.

Upvotes: 2

Related Questions