VanillaGranilla

photobooth.sh

May 16th, 2014
515
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.80 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #Copyright 2014 Jim Gronowski.  Released under the terms of the Apache 2.0 license
  4.  
  5. #photobooth.sh is a script to automate image processing and printing for unattended photobooths.  It was originally designed to work with Cheese webcam software, though the original source of images isn't important.  Any JPEGs dropped in $PHOTODIRECTORY will be combined into a filmstrip and are formatted to be printed on 4x6 or 5x7 paper.
  6.  
  7. PHOTODIRECTORY=/home/jgronowski/Pictures/Webcam
  8.  
  9. cd $PHOTODIRECTORY
  10.  
  11. #Continuous work loop, checks for 4 JPEGs, then begins processing.  Waits 10s, then starts over again.
  12. while true;
  13. do
  14.     echo "waiting for images..."
  15.     JPEGCOUNT=`ls *.jpg|wc -w`
  16.  
  17.     if [ $JPEGCOUNT -eq 4 ]
  18.     then
  19.         echo "Found images.  Processing..."
  20.    
  21.         # old way (no .jpg)- PHOTO2=`ls *.jpg|tail -n 3|head -n 1|sed 's/\.jpg//'`
  22.         PHOTO1=`ls *.jpg|tail -n 4|head -n 1`
  23.         PHOTO2=`ls *.jpg|tail -n 3|head -n 1`
  24.         PHOTO3=`ls *.jpg|tail -n 2|head -n 1`
  25.         PHOTO4=`ls *.jpg|tail -n 1|head -n 1`
  26.         FOOTER="footer.png"
  27.  
  28.         #echo "Photo 1: $PHOTO1"
  29.         #echo "Photo 2: $PHOTO2"
  30.         #echo "Photo 3: $PHOTO3"
  31.         #echo "Photo 4: $PHOTO4"
  32.         #echo "Photo footer: $FOOTER"
  33.  
  34.         convert $PHOTO1[800x800] $PHOTO2[800x800] $PHOTO3[800x800] $PHOTO4[800x800] $FOOTER[800x800] -background white -splice 0x10  -append -crop -0+10 out.png
  35.  
  36.         #Double up for printing
  37.         convert out.png out.png -background white -splice 15x0 +append -gravity east -crop -15+0 print.png
  38.  
  39.         #*****PRINT PHOTO HERE*****
  40.         echo "Printing photo..."   
  41.         lpr -o page-left=6 -o page-top=6 print.png
  42.    
  43.         #Clean up files
  44.         DATETIME="`date '+%Y%m%d%H%M%S'`"
  45.         mv *.jpg $PHOTODIRECTORY/originals/
  46.         mv out.png $PHOTODIRECTORY/filmstrips/$DATETIME.png
  47.         mv print.png $PHOTODIRECTORY/filmstrips/print$DATETIME.png
  48.  
  49.         echo "Done!"
  50.     fi
  51.  
  52.     sleep 10
  53. done
Advertisement
Add Comment
Please, Sign In to add comment