image optim

This commit is contained in:
Yann Esposito (Yogsototh) 2021-06-10 18:11:25 +02:00
parent 27e78c194b
commit e73e0fa702
Signed by untrusted user who does not match committer: yogsototh
GPG Key ID: 7B19A4C650D59646
1 changed files with 10 additions and 7 deletions

View File

@ -7,13 +7,16 @@ sizeof() {
stat --format="%s" "$*"
}
amount=0.33
s1=$( echo "100 * $amount" | bc -l )
s2=$( echo "100 / $amount" | bc -l )
# convert "$src" -resize 800x800\> -scale $s1% -scale $s2% -quality 50 "$dst"
convert "$src" -resize 800x800\> -ordered-dither o8x8,6 -colors 15 -quality 50 "$dst"
convert "$src" -resize 800x800\> -quality 50 "$dst"
before=$(sizeof $src)
after=$(sizeof $dst)
if (( before <= after )); then
cp -f "$src" "$dst"
print -- "[0%] cp $before => $before"
else
gain=$(( ( (before - after) * 100 ) / before ))
print -- "$before => $after [$gain%])"
print -- "[$gain%] convert $before => $after"
fi