Wed 13 Feb 2013
mac photobooth linux (bash) script with imagemagick
Posted by me under UncategorizedAdd Your Comments
Imagine you were tasked with a photobooth for your local non-profit’s group valentine’s day party. Imagine you’d need to setup a backdrop, photograph couples and then print out photo prints with a nice graphic overlay. How might you automate this all?
Step 1: with your canon camera, download the EOS utility which allows you to remotely control your camera and save the pictures to your harddrive immediately.
Step 2: create this bash script which combines the last four most recent photos onto a blank 8″x10″ (at 300dpi) and then puts a graphic overlay on top of them:
user@server:~/Pictures$ cat makeprint.sh #!/opt/local/bin/bash Col1X=95 Row1Y=80 Col2X=1400 Row2Y=1270 # Assume .JPG PONE=`ls *.JPG|tail -n 4|head -n 1|sed 's/\.JPG//'` PTWO=`ls *.JPG|tail -n 3|head -n 1|sed 's/\.JPG//'` PTHREE=`ls *.JPG|tail -n 2|head -n 1|sed 's/\.JPG//'` PFOUR=`ls *.JPG|tail -n 1|head -n 1|sed 's/\.JPG//'` echo "processing pics" echo "PONE: $PONE" echo "PTWO: $PTWO" echo "PTHREE: $PTHREE" echo "PFOUR: $PFOUR" #resize pics convert ${PONE}.JPG -resize 1300x867 ${PONE}_resized.JPG convert ${PTWO}.JPG -resize 1300x867 ${PTWO}_resized.JPG convert ${PTHREE}.JPG -resize 1300x867 ${PTHREE}_resized.JPG convert ${PFOUR}.JPG -resize 1300x867 ${PFOUR}_resized.JPG rm -f stage1.jpg rm -f stage2.jpg rm -f stage3.jpg rm -f stage4.jpg rm -f final.jpg #place resized image onto blank canvas composite -geometry +$Col1X+$Row1Y ${PONE}_resized.JPG blank_canvas.png stage1.jpg composite -geometry +$Col2X+$Col1X ${PTWO}_resized.JPG stage1.jpg stage2.jpg composite -geometry +$Col1X+$Row2Y ${PTHREE}_resized.JPG stage2.jpg stage3.jpg composite -geometry +$Col2X+$Row2Y ${PFOUR}_resized.JPG stage3.jpg stage4.jpg #add template on top composite valentine-photo-template.png stage4.jpg final.jpg rm -f ${PONE}_resized.JPG rm -r ${PTWO}_resized.JPG rm -f ${PTHREE}_resized.JPG rm -f ${PFOUR}_resized.JPG rm -f stage1.jpg rm -f stage2.jpg rm -f stage3.jpg rm -f stage4.jpg open -a Preview final.jpg mv ${PONE}.JPG printed/${PONE}.JPG mv ${PTWO}.JPG printed/${PTWO}.JPG mv ${PTHREE}.JPG printed/${PTHREE}.JPG mv ${PFOUR}.JPG printed/${PFOUR}.JPG lp -o landscape -o fit-to-page -o MediaType=hp-premium-photo-paper -o OutputMode=highest final.jpg
Step 3: you’ll need to have installed imagemagick
Here is a picture of my setup:

I took my list of Christmas Card Addresses and put them into a Google spreadsheet. The top row is the header row and has title, address1, address2, city, state and zip.