#!/bin/bash # # Blosxcam v0.1 (Phonecam for Blosxom) # # Get the latest at http://nocat.net/~rob/code/ # # Based on Phonecam v.5 by Matt Westervelt # http://seattlewireless.net/~mattw/badsoftware/phonecam/ # # Dependencies include convert, munpack, and procmail # # Installation is pretty straightforward. # Change the defaults and this rule to your .procmailrc # # :0 # * ^TOyoursecretaddress@yourdomain.com # | /home/username/bin/phonecam.sh # # Set the variables below to match your system # export PATH=/bin:/usr/bin:/usr/local/bin # Where should I put the blosxom entries? blosxom="/home/rob/blosxom/content/phonecam" # Where should I store the images? images="/home/rob/public_html/images/phonecam" # What is the base href for the images? imgbaseref="http://nocat.net/~rob/images/phonecam" # Default title for messages with no body title="Phonecam" # Email notification. Comment out to disable. notify="8005551212@mmode.com" # Thumbnail sizes for landscape and portrait tlandscape="240x160" tportrait="160x240" # Temp directory tmp="/tmp" ## ## Code below ## umask 022 if [ ! -d $blosxom ]; then mkdir -p $blosxom fi if [ ! -d $images ]; then mkdir -p $images fi if [ ! -d $images/thumbs ]; then mkdir -p $images/thumbs fi mkdir $tmp/.$$ cd $tmp/.$$ munpack > /dev/null 2>&1 for i in part? ; do sleep 1 time=`date +%s` f=`identify $i` a=`basename $i .jpg` mv $i $images/$time.jpg # # Identify portrait or landscape. # Here there be dragons. # # For old ImageMagick # f=${f/+0*/} # f=${f/* /} # # For new ImageMagick f=${f/ DirectClass*/} f=${f/*JPEG /} x=${f/x*/} y=${f/*x/} if [ "$x" -gt "$y" ]; then thumbsize=$tlandscape else thumbsize=$tportrait fi convert -resize $thumbsize $images/$time.jpg $images/thumbs/$time.jpg # make the new page if [ -f $a.desc ]; then head -1 $a.desc > $blosxom/$time.txt else echo "$title" > $blosxom/$time.txt fi echo "" >> $blosxom/$time.txt [ -f $a.desc ] && tail +2 $a.desc >> $blosxom/$time.txt echo "
" >> $blosxom/$time.txt done if [ "$notify" ]; then echo "Photo added to phonecam on `date`" | mail $notify fi rm -rf $tmp/.$$ # # End #