Skip to content

Instantly share code, notes, and snippets.

@jimmyctk
Last active January 13, 2023 02:34
Show Gist options
  • Save jimmyctk/c246cb9d64e2058b07a75ef1434d2475 to your computer and use it in GitHub Desktop.
Save jimmyctk/c246cb9d64e2058b07a75ef1434d2475 to your computer and use it in GitHub Desktop.
Drag and drop batch webp convert to png using dwebp on mac
#Download dwebp (WebP decoder tool) https://developers.google.com/speed/webp/download
#!/bin/bash
if ! command -v dwebp &> /dev/null
then
echo "dwebp could not be found"
if ! command -v brew &> /dev/null
then
echo "Homebrew could not be found"
exit
else
echo "Trying to install dwebp with Homebrew"
brew install webp
fi
fi
echo "Drag&Drop files/dirs and press enter when done."
IFS="" read -r input
eval "files=( $input )"
echo "Done"
for file in "${files[@]}"
do
filename=$(basename -- "$file")
extension="${filename##*.}"
filename="${filename%.*}"
path=$(dirname "$file")
dwebp -o "$path/$filename.png" "$path/$filename.webp"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment