In the quest for ultrafast websites and the every elusive four-hundos score in Google's lighthouse, I have recently begun to explore what are the best and fastest ways to convert JPG and PNG files to webp. Certainly I could use online tools to convert the images but then, there are concerns of course about webtools renaming files, modifying metadata, and of course having limits on them. Therefore I turned to a Mac users best friend homebrew where I found the wonderful Homebrew Formulae for webp. The tool is super easy to install and use.
- install homebrew
brew install webp
- press return
- wait
- navigate to the folder that has the image you want to convert
webp input.jpg -o output.webp
- press return Done
If you have a whole folder you wish to convert you can use Phil Warnath's super helpful script:
find . -type f \( -iname '*.png' -o -iname '*.jpg' -o -iname '*.jpeg' \) -exec sh -c 'cwebp -quiet "$1" -o "${1%.*}.webp"' _ {} \;