Last active
March 24, 2023 18:30
-
-
Save sheanhoxie/21dada66ab3e6324adb871445fb49fdc to your computer and use it in GitHub Desktop.
script to convert all images in a directory to webp, on mac osx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Install webp via Brew | |
brew install webp | |
cwebp [-preset <...>] [options] in_file [-o out_file] | |
options: | |
-o outfile | |
-q <float> quality 0-100 | |
-alpha_q <int> transparency compression 0-100 | |
-preset <string> default, photo, picture, drawing, icon, text | |
-preset must come first | |
-m compression (0=fast, 6=slow), default=4 | |
-size <int> target size (in bytes) | |
// Convert jpg to webp | |
for F in *.jpg; do cwebp -q 51 -m 5 $F -o `basename ${F%.jpg}`.webp; done | |
// Convert png to webp | |
for F in *.png; do cwebp $F -o `basename ${F%.png}`.webp; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment