ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/utils/cfutil.in
(Generate patch)

Comparing deliantra/server/utils/cfutil.in (file contents):
Revision 1.30 by root, Sat Apr 21 11:55:36 2007 UTC vs.
Revision 1.31 by root, Thu Apr 26 00:39:18 2007 UTC

9 9
10my $CONVERT = "@CONVERT@"; 10my $CONVERT = "@CONVERT@";
11my $IDENTIFY = "@IDENTIFY@"; 11my $IDENTIFY = "@IDENTIFY@";
12my $OPTIPNG = "@OPTIPNG@"; 12my $OPTIPNG = "@OPTIPNG@";
13my $RSYNC = "@RSYNC@"; 13my $RSYNC = "@RSYNC@";
14my $PNGNQ = "@PNGNQ@";
14 15
15use Getopt::Long; 16use Getopt::Long;
16use Coro::Event; 17use Coro::Event;
17use AnyEvent; 18use AnyEvent;
18use IO::AIO (); 19use IO::AIO ();
154 fork_sub { 155 fork_sub {
155 system "convert png:\Q$path\E -depth 8 rgba:-" 156 system "convert png:\Q$path\E -depth 8 rgba:-"
156 . "| $exec_prefix/bin/cfhq2xa $w $h $wrap" 157 . "| $exec_prefix/bin/cfhq2xa $w $h $wrap"
157 . "| convert -depth 8 -size ".($w * 2)."x".($h * 2)." rgba:- $QUANTIZE -quality 00 png32:\Q$other\E~" 158 . "| convert -depth 8 -size ".($w * 2)."x".($h * 2)." rgba:- $QUANTIZE -quality 00 png32:\Q$other\E~"
158 and die "convert/hq2xa pipeline error: status $? ($!)"; 159 and die "convert/hq2xa pipeline error: status $? ($!)";
159 system $OPTIPNG, "-o5", "-i0", "-q", "$other~"; 160 system $OPTIPNG, "-i0", "-q", "$other~";
160 die "$other~ has zero size, aborting." unless -s "$other~"; 161 die "$other~ has zero size, aborting." unless -s "$other~";
161 rename "$other~", $other; 162 rename "$other~", $other;
162 }; 163 };
163 } 164 }
164 165
170 my $other = "$stem.32x32.png~"; 171 my $other = "$stem.32x32.png~";
171 172
172 if (0 > aio_lstat $other or (-M _) > (-M $path)) { 173 if (0 > aio_lstat $other or (-M _) > (-M $path)) {
173 fork_sub { 174 fork_sub {
174 system "convert png:\Q$path\E -geometry 50% -filter lanczos $QUANTIZE -quality 00 png32:\Q$other\E~"; 175 system "convert png:\Q$path\E -geometry 50% -filter lanczos $QUANTIZE -quality 00 png32:\Q$other\E~";
175 system $OPTIPNG, "-o5", "-i0", "-q", "$other~"; 176 system $OPTIPNG, "-i0", "-q", "$other~";
177
178 # reduce smoothfaces >10000 bytes
179 if ($stem =~ /_S\./ && (-s "$other~") > 10000) {
180 my $ncolor = 256;
181 while () {
182 system "<\Q$other~\E $PNGNQ -n$ncolor >\Q$other~~\E";
183 system $OPTIPNG, "-i0", "-q", "$other~~";
184 last if 10000 > -s "$other~~";
185 $ncolor = int $ncolor * 0.9;
186 $ncolor > 8 or die "cannot reduce filesize to < 10000 bytes";
187 }
188
189 printf "reduced %s from %d to %d bytes using %d colours.\n",
190 $other, -s "$other~", -s "$other~~", $ncolor
191 if $VERBOSE > 0;
192 rename "$other~~", "$other~";
193 }
194
176 die "$other~ has zero size, aborting." unless -s "$other~"; 195 die "$other~ has zero size, aborting." unless -s "$other~";
177 rename "$other~", $other; 196 rename "$other~", $other;
178 }; 197 };
179 } 198 }
180 199

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines