#! /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