summaryrefslogtreecommitdiff
path: root/info/beginlatex/src/cutup
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /info/beginlatex/src/cutup
Initial commit
Diffstat (limited to 'info/beginlatex/src/cutup')
-rw-r--r--info/beginlatex/src/cutup80
1 files changed, 80 insertions, 0 deletions
diff --git a/info/beginlatex/src/cutup b/info/beginlatex/src/cutup
new file mode 100644
index 0000000000..11766509de
--- /dev/null
+++ b/info/beginlatex/src/cutup
@@ -0,0 +1,80 @@
+#! /bin/sh
+
+# Bourne shell script to cut slices of a JPG page image and make
+# separate JPG files from each line. It used to convert to PNM to get the
+# image size but this version assumes a whole uncropped page, so we give
+# absolute coordinates for the starting-point. The master page is made
+# by making a 1-page A4 PS file with dvips at 600dpi, then running GS on
+# it with DEVICE=jpeggray and r=300. If you use other settings, open the
+# JPG file in a graphics editor and work out initial values for LEFT, TOP,
+# WIDTH, and SLICE by yourself.
+
+# Peter Flynn, Silmaril Consultants, 2000/2001/2002/2003
+
+if [ -z "$1" ]; then
+
+ echo You must give a filename to slice up
+
+ exit 1
+
+else
+
+ FILE=`basename $1 .jpg`
+
+# Starting-point for TLC of first slice
+
+# LEFT=850
+# TOP=614
+
+ LEFT=1000
+ TOP=2300
+
+# WIDTH=`jpegtopnm $FILE.jpg | pnmfile | awk '{print $4}'`
+# WIDTH=$[WIDTH-LEFT]
+# WIDTH=1050
+
+ WIDTH=1000
+
+ HEIGHT=`jpegtopnm $FILE.jpg | pnmfile | awk '{print $6}'`
+
+ SLICE=50
+
+ BOTTOM=$SLICE
+
+# we expect 36 lines of font samples
+
+ while [ $BOTTOM -lt $HEIGHT ]; do
+
+ BOTTOM=$[TOP+SLICE-1]
+
+ COUNT=$[COUNT+1]
+
+ if [ $COUNT -lt 10 ]; then
+ SEQ="0"$COUNT
+ else
+ SEQ=$COUNT
+ fi
+
+ echo Cutting slice $COUNT from $TOP to $BOTTOM
+
+ jpegtopnm $FILE.jpg | pnmcut $LEFT $TOP $WIDTH $SLICE | pnmcrop | ppmtojpeg >$FILE-$SEQ.jpg
+
+ TOP=$[BOTTOM+1]
+
+# additional spacing to skip over table subheadings
+
+ if [ $COUNT = 21 ]; then
+
+ TOP=$[TOP + 136 - $SLICE]
+
+ elif [ $COUNT = 31 ]; then
+
+ TOP=$[TOP + 136 - $SLICE]
+
+ fi
+
+ done
+
+fi
+
+exit 0 \ No newline at end of file