41761fdc |
1 | #! /usr/bin/perl |
2 | |
3 | $| = 1; |
4 | $np = 0; |
5 | |
6 | $in = shift or die("bad arg"); |
7 | open IN, $in or die("open `$in': $!"); |
8 | while (<IN>) { |
9 | $np = $1, last if /^%%Pages:\s*(\d+)\s*$/; |
10 | } |
11 | die("no pages") unless $np; |
12 | |
13 | sub sel($) { sprintf("tmp.sel.%05d.ps", $_[0]); } |
14 | sub image($) { sprintf("img%05d.png", $_[0]); } |
15 | |
16 | END { |
17 | for ($i = 1; $i <= $np; $i++) { |
18 | unlink(sel($i)); |
19 | } |
20 | } |
21 | |
22 | print "converting..."; |
23 | for ($p = 1; $p <= $np; $p++) { |
24 | print " ["; |
25 | system qw"psselect -q -p", $p, $in, sel($p) and die("psselect: $?"); |
26 | print "$p"; |
27 | system qw"convert |
28 | -density 300 -antialias -geometry 600x800 -rotate -90 |
29 | -bordercolor black -border 0x17", |
30 | sel($p), image($p) and die("convert: $?"); |
31 | print "]"; |
32 | unlink(sel($p)); |
33 | } |
34 | print "\n"; |