fix: Add check for whether a WebP file is animated (cwebp does not support compressing animated files)
This commit is contained in:
parent
badc0d824f
commit
164641f5f7
1 changed files with 12 additions and 8 deletions
|
@ -29,16 +29,20 @@ loop_1(){
|
||||||
nice -n 10 oxipng -o max "${p}" #&> /dev/null
|
nice -n 10 oxipng -o max "${p}" #&> /dev/null
|
||||||
elif [[ "${p}" =~ .webp ]]
|
elif [[ "${p}" =~ .webp ]]
|
||||||
then
|
then
|
||||||
nice -n 10 cwebp -mt -af -quiet "${p}" -o /tmp/temp.webp #&> /dev/null
|
#If file is not animated
|
||||||
if [[ -f /tmp/temp.webp ]]
|
if [[ $(grep -v -q -e "ANIM" -e "ANMF" "${p}" ]]
|
||||||
then
|
then
|
||||||
size_new=$(stat -c%s "/tmp/temp.webp" || 0 )
|
nice -n 10 cwebp -mt -af -quiet "${p}" -o /tmp/temp.webp #&> /dev/null
|
||||||
size_original=$(stat -c%s "${p}")
|
if [[ -f /tmp/temp.webp ]]
|
||||||
if [[ "${size_original}" -gt "${size_new}" ]]
|
|
||||||
then
|
then
|
||||||
mv /tmp/temp.webp "${p}" #&> /dev/null
|
size_new=$(stat -c%s "/tmp/temp.webp" || 0 )
|
||||||
else
|
size_original=$(stat -c%s "${p}")
|
||||||
rm /tmp/temp.webp #&> /dev/null
|
if [[ "${size_original}" -gt "${size_new}" ]]
|
||||||
|
then
|
||||||
|
mv /tmp/temp.webp "${p}" #&> /dev/null
|
||||||
|
else
|
||||||
|
rm /tmp/temp.webp #&> /dev/null
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Reference in a new issue