--- deliantra/server/utils/cfutil.in 2007/08/18 20:39:14 1.51 +++ deliantra/server/utils/cfutil.in 2007/08/18 22:25:35 1.52 @@ -174,10 +174,53 @@ if (0 > aio_lstat $other or (-M _) > (-M $path)) { fork_sub { - system "convert -depth 8 png:\Q$path\E rgba:-" + my $CROP; + my $SRC = "png:\Q$path\E"; + + # check if this is a wall. ultra-ugly. ultra-ultra-ugly. + if ($path =~ /^(.*\/wall\/.*_)([0-9A-F])(\.x11.*\.png)$/) { + my ($pfx, $dir, $sfx) = ($1, hex $2, $3); + #check for 0..F images to be sure(?) this is a wall + unless (grep { !-e sprintf "%s%X%s", $pfx, $_, $sfx } 0..15) { + # add a 4px border and add other images around it + $CROP = "-shave 8x8 +repage"; + + $w += 8; + $h += 8; + + $SRC = "-size ${w}x${h} xc:transparent"; + $SRC .= " png:\Q$path\E -geometry +4+4 -composite"; + + # 8 surrounding images + for ( + # x y b r0 r1 + [-1, -1, 0, 6], + [ 0, -1, 1, 10, 14], + [+1, -1, 0, 12], + + [-1, 0, 8, 5, 7], + # + [+1, 0, 2, 5, 13], + + [-1, +1, 0, 3], + [ 0, +1, 4, 10, 11], + [+1, +1, 0, 9], + ) { + my ($x, $y, $d, $r0, $r1) = @$_; + $SRC .= sprintf " png:%s%X%s -geometry %+d%+d -composite", + "\Q$pfx", + ($dir & $d) ? $r1 : $r0, + "\Q$sfx", + $x * ($w - 8) + 4, + $y * ($h - 8) + 4; + } + } + } + + system "convert -depth 8 $SRC rgba:-" . "| $exec_prefix/bin/cfhq2xa $w $h 0" - . "| convert -depth 8 -size ".($w * 2)."x".($h * 2)." rgba:- $QUANTIZE -quality 00 png32:\Q$other\E~" - and die "convert/hq2xa pipeline error: status $? ($!)"; + . "| convert -depth 8 -size ".($w * 2)."x".($h * 2)." rgba:- $CROP $QUANTIZE -quality 00 png32:\Q$other\E~" + and die "convert/cfhq2xa pipeline error: status $? ($!)"; system $OPTIPNG, "-i0", "-q", "$other~"; die "$other~ has zero size, aborting." unless -s "$other~"; rename "$other~", $other;