commit ad743d318aec6732b8899834355bb926dd1897a9
parent ab6e4fcc88b636a2ec0488692d63105dbd301b40
Author: Antoine Amarilli <a3nm@a3nm.net>
Date: Sat, 7 Sep 2019 00:20:38 +0200
explain master.sh
Diffstat:
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/master.sh b/master.sh
@@ -12,14 +12,22 @@ FIXCMD="${7-echo 'not fixing anything'}"
mkdir -p tmp pages lines chunks outpages
-TMPDIR=./tmp convert -background white -alpha remove -alpha off \ -quality 100 -density "$DENSITY" "$FILE" pages/page_%04d.png
+# convert pdf to one image for each page
+TMPDIR=./tmp convert -background white -alpha remove -alpha off \
+ -quality 100 -density "$DENSITY" "$FILE" pages/page_%04d.png
+# convert each page to lines
ls pages/* | parallel ./splith.py --maxheight=$(($HEIGHT-2*$MARGIN)) '{}' ./lines/
+# convert each line to chunks
ls lines/* | parallel ./splitw.py '{}' ./chunks/ $(($WIDTH-2*$MARGIN))
+# ad-hoc hook to fix some things
$FIXCMD "$(($WIDTH-2*$MARGIN))"
+# combine chunks into output pages
./combine.py --hmargin="$MARGIN" --vmargin="$MARGIN" chunks/ outpages/ "$HEIGHT"
+
+# create output pdf
ls outpages/*.png | while read a ; do echo $a; convert -interpolate bilinear $a ${a%.png}.pdf; done
pdftk outpages/*.pdf cat output "$OUTFILE"