summaryrefslogtreecommitdiff
path: root/scan-images.sh
blob: b538cae22157248a1906de3ae53bbf551fef2258 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#! /bin/bash -xe

# Query user for directory containing the scan images
IMAGE_DIRECTORY=$(zenity --file-selection --directory --text="Choose folder with ultrasound images")

# If dialog box was cancelled, exit and do nothing
if [[ -z $IMAGE_DIRECTORY ]]
then
    exit
fi

IMAGE_FILES=$(ls $IMAGE_DIRECTORY/*.tif)
IMAGE_WIDTH=$(identify -format "%w" $(ls $IMAGE_DIRECTORY/*.tif | head -n 1))
MONTAGE_OUTFILE=$(mktemp --suffix=".pdf")

# Create montage of scan images
montage -geometry $IMAGE_WIDTH -tile 2x3 $IMAGE_FILES $MONTAGE_OUTFILE
# Send to printer, and delete from memory
lpr -r -o sides=two-sided-long-edge -o fit-to-page -o page-left=72 -o page-right=72 $MONTAGE_OUTFILE