Compare commits
2 Commits
f706a02651
...
1b89ba7e38
Author | SHA1 | Date | |
---|---|---|---|
|
1b89ba7e38 | ||
|
41e9a60660 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@ images
|
||||
logs
|
||||
synthesis
|
||||
*swp
|
||||
stamps
|
||||
|
34
page_generator.sh
Executable file
34
page_generator.sh
Executable file
@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
|
||||
IMG=$1
|
||||
COUNT_HORIZONTAL=$2
|
||||
COUNT_VERTICAL=$3
|
||||
LANDSCAPE=${4}
|
||||
|
||||
panic(){ echo $@; exit 2; }
|
||||
|
||||
[[ ! -f $IMG ]] && panic "$IMG does not exist"
|
||||
|
||||
SMALL_SIDE=4000
|
||||
LARGE_SIDE=5800
|
||||
|
||||
# /tmp/out.pdf PDF 567x822 567x822+0+0 16-bit sRGB 980KB 0.010u 0:00.009
|
||||
read name type GEOMETRY canvas depth format size other <<< $( identify $IMG )
|
||||
IMG_WIDTH=$( cut -d "x" -f 1 <<< $GEOMETRY )
|
||||
IMG_HEIGHT=$( cut -d "x" -f 2 <<< $GEOMETRY )
|
||||
|
||||
TOTAL_WIDTH=$( [[ -n "$LANDSCAPE" ]] && echo $LARGE_SIDE || echo $SMALL_SIDE )
|
||||
TOTAL_HEIGHT=$( [[ -n "$LANDSCAPE" ]] && echo $SMALL_SIDE || echo $LARGE_SIDE )
|
||||
|
||||
REQ_WIDTH=$(( $TOTAL_WIDTH / $COUNT_HORIZONTAL ))
|
||||
REQ_HEIGHT=$(( $TOTAL_HEIGHT / $COUNT_VERTICAL ))
|
||||
|
||||
DUP=$(( ( $COUNT_HORIZONTAL * $COUNT_VERTICAL ) - 1 ))
|
||||
|
||||
DATE=$( date +%s )
|
||||
OUTPUT_DIR=/tmp
|
||||
FILENAME=$( basename $IMG )
|
||||
PDF_NAME=${OUTPUT_DIR}/${DATE}_${FILENAME}.pdf
|
||||
OUT=$( montage -tile ${COUNT_HORIZONTAL}x${COUNT_VERTICAL} -density 200x200 -units pixelspercentimeter -border 0 -page ${TOTAL_WIDTH}x${TOTAL_HEIGHT} "$IMG" -geometry ${REQ_WIDTH}x${REQ_HEIGHT} -duplicate ${DUP},0 ${PDF_NAME} )
|
||||
|
||||
[ 0 -eq $? ] && echo $PDF_NAME || panic "An error occured... $OUT"
|
Loading…
Reference in New Issue
Block a user