Browse Source

image optim

exp-with-scrum
parent
commit
e73e0fa702
Signed by: yogsototh GPG Key ID: 7B19A4C650D59646
  1. 17
      engine/optim-img.sh

17
engine/optim-img.sh

@ -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)
gain=$(( ( (before - after) * 100 ) / before ))
print -- "$before => $after [$gain%])"
if (( before <= after )); then
cp -f "$src" "$dst"
print -- "[0%] cp $before => $before"
else
gain=$(( ( (before - after) * 100 ) / before ))
print -- "[$gain%] convert $before => $after"
fi

Loading…
Cancel
Save