Skip to content

Instantly share code, notes, and snippets.

@kelvinblood
Created December 4, 2018 05:56
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kelvinblood/0350f50be92ccbd5036ded07980653ea to your computer and use it in GitHub Desktop.
Save kelvinblood/0350f50be92ccbd5036ded07980653ea to your computer and use it in GitHub Desktop.
webp2jpg
#!/bin/bash
for file in `ls`
do
len3=`xxd -p -l 3 $file`
len4=`xxd -p -l 4 $file`
echo -n $file
if [ $len3 == "ffd8ff" ]; then
echo " is jpg"
elif [ $len4 == "89504e47" ]; then
echo " is png"
elif [ $len4 == "47494638" ]; then
echo " is gif"
elif [ $len4 == "52494646" ]; then
echo " is webp"
if [ ! -e $file.jpg ]; then
echo "===== convert $file ====="
dwebp $file -o $file.png
convert "$file.png" "$file.jpg"
rm $file.png
fi
else
echo " is others"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment