-
Notifications
You must be signed in to change notification settings - Fork 0
/
ass.pl
80 lines (59 loc) · 1.87 KB
/
ass.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/local/perl
# use JSON::Parse 'parse_json';
# use Date::Parse;
use JSON::Parse qw(parse_json json_file_to_perl);
use Date::Parse;
use Date::Format;
use List::MoreUtils qw(uniq);
use List::Util qw(shuffle);
# assemble
# this is going to be ugly
print "Assembling...\n";
# a general purpose blank page
system("convert -size 1000x1600 xc:white img/tmp/pages/blank.png");
# front matter
my @frontMatter = ("cover", "blank", "titlePage", "about", "toc", "blank");
# makeBackCover();
my @backMatter = ("end", "blank", "backCover");
# make a PDF
print "Making a PDF .. \n";
system("mogrify -format pdf img/tmp/pages/*.png");
$pdffront = join(" ", map {"img/tmp/pages/" . $_ . ".pdf"} @frontMatter);
my @pdfpages = glob "img/tmp/pages/page-*.pdf";
$pdfs = join(" ", @pdfpages);
$pdfback = join(" ", map {"img/tmp/pages/" . $_ . ".pdf"} @backMatter);
system("pdftk $pdffront $pdfs $pdfback cat output output/book.pdf");
#make a CBR
print "Making a CBR...\n";
system("mogrify -format jpg -quality 80 img/tmp/pages/*.png");
@jpgfront = map {"img/tmp/pages/" . $_ . ".jpg"} @frontMatter;
@jpgpages = glob "img/tmp/pages/page-*.jpg";
@jpgback = map {"img/tmp/pages/" . $_ . ".jpg"} @backMatter;
my $cbpn = 0;
foreach(@jpgfront){
$tg = $_;
$tg =~ s/img\/tmp\/pages\///i;
$ppn = sprintf("%03d", $cbpn);
system("mv $_ img/tmp/pages/$ppn-$tg");
$cbpn += 1;
}
foreach(@jpgpages){
$tg = $_;
$tg =~ s/img\/tmp\/pages\///i;
$ppn = sprintf("%03d", $cbpn);
system("mv $_ img/tmp/pages/$ppn-$tg");
$cbpn += 1;
}
foreach(@jpgback){
$tg = $_;
$tg =~ s/img\/tmp\/pages\///i;
$ppn = sprintf("%03d", $cbpn);
system("mv $_ img/tmp/pages/$ppn-$tg");
$cbpn += 1;
}
#$cbrpages = join(" ", @jpgfront) . " " . join(" ", @jpgpages) . " " . join(" ", @jpgback);
@cbrpages = glob "img/tmp/pages/*.jpg";
$cbrs = join (" ", @cbrpages);
system("rar a output/book.cbr $cbrpages");
print "Done!?\n";
exit;