… | |
… | |
177 | |
177 | |
178 | # reduce smoothfaces >10000 bytes |
178 | # reduce smoothfaces >10000 bytes |
179 | if ($stem =~ /_S\./ && (-s "$other~") > 10000) { |
179 | if ($stem =~ /_S\./ && (-s "$other~") > 10000) { |
180 | my $ncolor = 256; |
180 | my $ncolor = 256; |
181 | while () { |
181 | while () { |
182 | system "<\Q$other~\E $PNGNQ -n$ncolor >\Q$other~~\E"; |
182 | system "<\Q$other~\E $PNGNQ -s1 -n$ncolor >\Q$other~~\E"; |
183 | system $OPTIPNG, "-i0", "-q", "$other~~"; |
183 | system $OPTIPNG, "-i0", "-q", "$other~~"; |
184 | last if 10000 > -s "$other~~"; |
184 | last if 10000 > -s "$other~~"; |
185 | $ncolor = int $ncolor * 0.9; |
185 | $ncolor = int $ncolor * 0.9; |
186 | $ncolor > 8 or die "cannot reduce filesize to < 10000 bytes"; |
186 | $ncolor > 8 or die "cannot reduce filesize to < 10000 bytes"; |
187 | } |
187 | } |
188 | |
188 | |
189 | printf "reduced %s from %d to %d bytes using %d colours.\n", |
189 | printf "reduced %s from %d to %d bytes using %d colours.\n", |
190 | $other, -s "$other~", -s "$other~~", $ncolor |
190 | $other, -s "$other~", -s "$other~~", $ncolor |
191 | if $VERBOSE > 0; |
191 | if $VERBOSE >= 2; |
192 | rename "$other~~", "$other~"; |
192 | rename "$other~~", "$other~"; |
193 | } |
193 | } |
194 | |
194 | |
195 | die "$other~ has zero size, aborting." unless -s "$other~"; |
195 | die "$other~ has zero size, aborting." unless -s "$other~"; |
196 | rename "$other~", $other; |
196 | rename "$other~", $other; |
… | |
… | |
386 | } elsif ($file =~ /\.trs$/) { |
386 | } elsif ($file =~ /\.trs$/) { |
387 | push @trs, [$path, $file]; |
387 | push @trs, [$path, $file]; |
388 | } elsif ($file =~ /\.arc$/) { |
388 | } elsif ($file =~ /\.arc$/) { |
389 | push @arc, [$path, $file]; |
389 | push @arc, [$path, $file]; |
390 | } else { |
390 | } else { |
391 | warn "ignoring $path/$file\n" if $VERBOSE >= 2; |
391 | warn "ignoring $path/$file\n" if $VERBOSE >= 3; |
392 | } |
392 | } |
393 | } |
393 | } |
394 | }; |
394 | }; |
395 | } |
395 | } |
396 | |
396 | |