Last active
January 13, 2023 02:34
-
-
Save jimmyctk/c246cb9d64e2058b07a75ef1434d2475 to your computer and use it in GitHub Desktop.
Drag and drop batch webp convert to png using dwebp on mac
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
#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