Created
December 4, 2018 05:56
-
-
Save kelvinblood/0350f50be92ccbd5036ded07980653ea to your computer and use it in GitHub Desktop.
webp2jpg
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
#!/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