Skip to content

Instantly share code, notes, and snippets.

@seasonedgeek
Last active May 3, 2020 02:43
Show Gist options
  • Save seasonedgeek/725aa69d057c32aec3297f2d271cd195 to your computer and use it in GitHub Desktop.
Save seasonedgeek/725aa69d057c32aec3297f2d271cd195 to your computer and use it in GitHub Desktop.
Uses Google's WebP `dwebp` to decompress `webp` images into `png` images.
#!/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