fix: Improve the parsing of animated WebP files in case they're erased before testing
This commit is contained in:
parent
4414225297
commit
64442a97b3
3 changed files with 55 additions and 45 deletions
|
@ -19,15 +19,17 @@ loop_1() {
|
||||||
nice -n 10 oxipng -o max "${p}" #&> /dev/null
|
nice -n 10 oxipng -o max "${p}" #&> /dev/null
|
||||||
elif [[ "${p}" =~ Web/P ]]; then
|
elif [[ "${p}" =~ Web/P ]]; then
|
||||||
#If file is not animated
|
#If file is not animated
|
||||||
if grep -v -q -e "ANIM" -e "ANMF" "${p}"; then
|
if [[ -f "${p}" ]]; then
|
||||||
nice -n 10 cwebp -mt -af -quiet "${p}" -o /tmp/temp.webp #&> /dev/null
|
if grep -v -q -e "ANIM" -e "ANMF" "${p}"; then
|
||||||
if [[ -f /tmp/temp.webp ]]; then
|
nice -n 10 cwebp -mt -af -quiet "${p}" -o /tmp/temp.webp #&> /dev/null
|
||||||
size_new=$(stat -c%s "/tmp/temp.webp" || 0)
|
if [[ -f /tmp/temp.webp ]]; then
|
||||||
size_original=$(stat -c%s "${p}")
|
size_new=$(stat -c%s "/tmp/temp.webp" || 0)
|
||||||
if [[ "${size_original}" -gt "${size_new}" ]]; then
|
size_original=$(stat -c%s "${p}")
|
||||||
mv /tmp/temp.webp "${p}" #&> /dev/null
|
if [[ "${size_original}" -gt "${size_new}" ]]; then
|
||||||
else
|
mv /tmp/temp.webp "${p}" #&> /dev/null
|
||||||
rm /tmp/temp.webp #&> /dev/null
|
else
|
||||||
|
rm /tmp/temp.webp #&> /dev/null
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -26,15 +26,17 @@ loop_1() {
|
||||||
nice -n 10 oxipng -o max "${p}" #&> /dev/null
|
nice -n 10 oxipng -o max "${p}" #&> /dev/null
|
||||||
elif [[ "${p}" =~ .webp ]]; then
|
elif [[ "${p}" =~ .webp ]]; then
|
||||||
#If file is not animated
|
#If file is not animated
|
||||||
if ! grep -v -q -e "ANIM" -e "ANMF" "${p}"; then
|
if [[ -f "${p}" ]]; then
|
||||||
nice -n 10 cwebp -mt -af -quiet "${p}" -o /tmp/temp.webp #&> /dev/null
|
if grep -q -v -e "ANIM" -e "ANMF" "${p}"; then
|
||||||
if [[ -f /tmp/temp.webp ]]; then
|
nice -n 10 cwebp -mt -af -quiet "${p}" -o /tmp/temp.webp #&> /dev/null
|
||||||
size_new=$(stat -c%s "/tmp/temp.webp" || 0)
|
if [[ -f /tmp/temp.webp ]]; then
|
||||||
size_original=$(stat -c%s "${p}")
|
size_new=$(stat -c%s "/tmp/temp.webp" || 0)
|
||||||
if [[ "${size_original}" -gt "${size_new}" ]]; then
|
size_original=$(stat -c%s "${p}")
|
||||||
mv /tmp/temp.webp "${p}" #&> /dev/null
|
if [[ "${size_original}" -gt "${size_new}" ]]; then
|
||||||
else
|
mv /tmp/temp.webp "${p}" #&> /dev/null
|
||||||
rm /tmp/temp.webp #&> /dev/null
|
else
|
||||||
|
rm /tmp/temp.webp #&> /dev/null
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -37,15 +37,17 @@ wait
|
||||||
#compress-webp
|
#compress-webp
|
||||||
while read -r s; do
|
while read -r s; do
|
||||||
#If file is not animated
|
#If file is not animated
|
||||||
if ! grep -v -q -e "ANIM" -e "ANMF" "${s}"; then
|
if [[ -f "${s}" ]]; then
|
||||||
cwebp -mt -af -quiet "${s}" -o /tmp/"${s##.*\/}"_temp.webp #&>/dev/null
|
if grep -v -q -e "ANIM" -e "ANMF" "${s}"; then
|
||||||
if [[ -f /tmp/"${s##.*\/}"_temp.webp ]]; then
|
cwebp -mt -af -quiet "${s}" -o /tmp/"${s##.*\/}"_temp.webp #&>/dev/null
|
||||||
size_new=$(stat -c%s /tmp/"${s##.*\/}"_temp.webp || 0)
|
if [[ -f /tmp/"${s##.*\/}"_temp.webp ]]; then
|
||||||
size_original=$(stat -c%s "${s}" || 0)
|
size_new=$(stat -c%s /tmp/"${s##.*\/}"_temp.webp || 0)
|
||||||
if [[ -n "${size_original}" && -n "${size_new}" && "${size_original}" -gt "${size_new}" ]]; then
|
size_original=$(stat -c%s "${s}" || 0)
|
||||||
mv /tmp/"${s##.*\/}"_temp.webp "${s}"
|
if [[ -n "${size_original}" && -n "${size_new}" && "${size_original}" -gt "${size_new}" ]]; then
|
||||||
else
|
mv /tmp/"${s##.*\/}"_temp.webp "${s}"
|
||||||
rm /tmp/"${s##.*\/}"_temp.webp
|
else
|
||||||
|
rm /tmp/"${s##.*\/}"_temp.webp
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -76,15 +78,17 @@ while read -r j; do
|
||||||
elif file -b "${j}" | grep -q "Web/P"; then
|
elif file -b "${j}" | grep -q "Web/P"; then
|
||||||
mv "${j}" "${j%.*}".webp
|
mv "${j}" "${j%.*}".webp
|
||||||
#If file is not animated
|
#If file is not animated
|
||||||
if ! grep -v -q -e "ANIM" -e "ANMF" "${s}"; then
|
if [[ -f "${j}" ]]; then
|
||||||
cwebp -mt -af -quiet "${s}" -o /tmp/"${s##.*\/}"_temp.webp #&>/dev/null
|
if grep -v -q -e "ANIM" -e "ANMF" "${s}"; then
|
||||||
if [[ -f /tmp/"${s##.*\/}"_temp.webp ]]; then
|
cwebp -mt -af -quiet "${s}" -o /tmp/"${s##.*\/}"_temp.webp #&>/dev/null
|
||||||
size_new=$(stat -c%s /tmp/"${s##.*\/}"_temp.webp || 0)
|
if [[ -f /tmp/"${s##.*\/}"_temp.webp ]]; then
|
||||||
size_original=$(stat -c%s "${s}" || 0)
|
size_new=$(stat -c%s /tmp/"${s##.*\/}"_temp.webp || 0)
|
||||||
if [[ -n "${size_original}" && -n "${size_new}" && "${size_original}" -gt "${size_new}" ]]; then
|
size_original=$(stat -c%s "${s}" || 0)
|
||||||
mv /tmp/"${s##.*\/}"_temp.webp "${s}"
|
if [[ -n "${size_original}" && -n "${size_new}" && "${size_original}" -gt "${size_new}" ]]; then
|
||||||
else
|
mv /tmp/"${s##.*\/}"_temp.webp "${s}"
|
||||||
rm /tmp/"${s##.*\/}"_temp.webp
|
else
|
||||||
|
rm /tmp/"${s##.*\/}"_temp.webp
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -102,15 +106,17 @@ while read -r k; do
|
||||||
elif file -b "${k}" | grep -q "Web/P"; then
|
elif file -b "${k}" | grep -q "Web/P"; then
|
||||||
mv "${k}" "${k%.*}".webp
|
mv "${k}" "${k%.*}".webp
|
||||||
#If file is not animated
|
#If file is not animated
|
||||||
if ! grep -v -q -e "ANIM" -e "ANMF" "${s}"; then
|
if [[ -f "${k}" ]]; then
|
||||||
cwebp -mt -af -quiet "${s}" -o /tmp/"${s##.*\/}"_temp.webp #&>/dev/null
|
if grep -v -q -e "ANIM" -e "ANMF" "${s}"; then
|
||||||
if [[ -f /tmp/"${s##.*\/}"_temp.webp ]]; then
|
cwebp -mt -af -quiet "${s}" -o /tmp/"${s##.*\/}"_temp.webp #&>/dev/null
|
||||||
size_new=$(stat -c%s /tmp/"${s##.*\/}"_temp.webp || 0)
|
if [[ -f /tmp/"${s##.*\/}"_temp.webp ]]; then
|
||||||
size_original=$(stat -c%s "${s}" || 0)
|
size_new=$(stat -c%s /tmp/"${s##.*\/}"_temp.webp || 0)
|
||||||
if [[ -n "${size_original}" && -n "${size_new}" && "${size_original}" -gt "${size_new}" ]]; then
|
size_original=$(stat -c%s "${s}" || 0)
|
||||||
mv /tmp/"${s##.*\/}"_temp.webp "${s}"
|
if [[ -n "${size_original}" && -n "${size_new}" && "${size_original}" -gt "${size_new}" ]]; then
|
||||||
else
|
mv /tmp/"${s##.*\/}"_temp.webp "${s}"
|
||||||
rm /tmp/"${s##.*\/}"_temp.webp
|
else
|
||||||
|
rm /tmp/"${s##.*\/}"_temp.webp
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Reference in a new issue