X-Git-Url: http://git.rot13.org/?p=Printer-Zebra.git;a=blobdiff_plain;f=svg-render.pl;h=e73ae0e4d94c119f9509c69b16396e49e248484f;hp=6624066f1a2f907a6b925b5dc590ed65043a2287;hb=19ea357698992dfea94dfc919c6efe22917b4a7c;hpb=9ce1aa4d7c717cedf9f49896e4a40e8dcd717414 diff --git a/svg-render.pl b/svg-render.pl index 6624066..e73ae0e 100755 --- a/svg-render.pl +++ b/svg-render.pl @@ -1,16 +1,41 @@ #!/usr/bin/perl use warnings; use strict; +use autodie; # 5166 px = 1000 dpi +my $size = $ENV{SIZE} || '105x40'; + my $w = 832; my $density = $w / 5166 * 1000; warn "# density = $density\n"; -my $from = shift @ARGV || die "usage: $0 template.svg\n"; -system "convert -density $density $from $from.pbm"; +my $barcode = shift @ARGV || die "usage: $0 1301272944 callnumber\n"; + +my $call1 = shift @ARGV; +my $call2 = shift @ARGV; +my $call3 = shift @ARGV; +my $call4 = join(' ', @ARGV); + +my $pbm = "/tmp/$barcode.pbm"; + +open(my $from, '<', "templates/$size.svg"); +open(my $to, '|-', "convert -density $density - $pbm"); +while(<$from>) { + s/1301272944/$barcode/gs && warn "# barcode $barcode\n"; + s/##call1##/$call1/gs && warn "# 1: $call1\n"; + s/##call2##/$call2/gs && warn "# 2: $call2\n"; + s/##call3##/$call3/gs && warn "# 3: $call3\n"; + s/##call4##/$call4/gs && warn "# 4: $call4\n"; + + print $to $_; +} +close($from); +close($to); + +warn "$pbm ", -s $pbm, " bytes\n";