Last active
May 10, 2022 19:12
-
-
Save najathi/ea098fd438b98f77b1e061d15c79f7ab to your computer and use it in GitHub Desktop.
jpg, png, gif, .etc. to webp using choco with webp
This file contains hidden or 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
1. install the choco | |
https://docs.chocolatey.org/en-us/choco/setup | |
2.choco install webp | |
more info, checkout here | |
https://www.smashingmagazine.com/2018/07/converting-images-to-webp/ | |
3. a file conversion | |
cwebp -q 75 test.jpg -o output.webp | |
4. a file conversion with output directory | |
mkdir images && cwebp -q 75 test.jpg -o images/output.webp | |
5. bulk images find | |
find ./ -type f -name '*.jpg' | |
6. bulk images conversion | |
find ./ -type f -name '*.jpg' -exec sh -c 'cwebp -q 75 $1 -o "${1%.jpg}.webp"' _ {} \; | |
7. bulk images coversion with output directory | |
mkdir output && find ./ -type f -name '*.jpg' -exec sh -c 'cwebp -q 75 $1 -o "output/${1%.jpg}.webp"' _ {} \; | |
8. keep old file name and bulk images coversion with output directory | |
mkdir output && for filename in ./*.png; do cwebp -q 75 "$filename" -o "./output/${filename%.*}.webp"; done; | |
9. bulk images coversion with output directory to sequential numbers | |
mkdir output && ls -v | cat -n | while read n f; do cwebp -q 75 "$f" -o "./output/${n%.*}.webp"; done | |
9. bulk rename and images coversion with output directory to sequential numbers | |
ls -v | cat -n | while read n f; do mv -n "$f" "$n.jpg"; done && | |
mkdir output && | |
ls -v | cat -n | while read n f; do cwebp -q 75 "$f" -o "./output/${n%.*}.webp"; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment