Last active
May 3, 2020 02:43
-
-
Save seasonedgeek/725aa69d057c32aec3297f2d271cd195 to your computer and use it in GitHub Desktop.
Uses Google's WebP `dwebp` to decompress `webp` images into `png` images.
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
#!/usr/bin/env zsh | |
# decompWebp.zsh - Decompresses WebP files into PNG files. | |
set basedir=$1 | |
for file in ${basedir}/**/*.webp ; do | |
# ext = PNG, PAM, PPM or PGM | |
ext=".png" | |
src=(${file:t}) | |
dest=(${file:t:r}) | |
pngfile=${dest}${ext} | |
echo "Decompress ${src} into ${pngfile}" | |
dwebp ${src} -o ${pngfile} | |
# optional: keep images in separate folders | |
mv ${pngfile} ${basedir}/pngs/ | |
done | |
# optional: archieve webp images? | |
zip ${basedir}/webp-archieve.zip ${basedir}/*.webp | |
# optional: dont need these? | |
rm ${basedir}/*.webp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment