Skip to content

Instantly share code, notes, and snippets.

@Lmd64-zz
Created October 29, 2014 17:51
Show Gist options
  • Save Lmd64-zz/c0623e80226c7dc01c0d to your computer and use it in GitHub Desktop.
Save Lmd64-zz/c0623e80226c7dc01c0d to your computer and use it in GitHub Desktop.
Snap Webcam And Caption It
mkdir -p ~/Pictures/BuildPhotos ; \
cd ~/Pictures/BuildPhotos ; \
photoPath="$(date +%y%m%d%H%M%S).png" ; \
resizedPhotoPath="resized-$(date +%y%m%d%H%M%S).png" ; \
/usr/local/bin/imagesnap -w 1 $photoPath ; \
topCaption='this is a test' ; \
topCaption="$(echo ${topCaption} | tr '[:lower:]' '[:upper:]')" ; \
bottomCaption='...which is resulting in a large amount of text that displays much text in this text' ; \
bottomCaption="$(echo ${bottomCaption} | tr '[:lower:]' '[:upper:]')" ; \
convert $photoPath -resize 320x320\> -size 320x -gravity south $resizedPhotoPath ; \
width=`identify -format %w ${resizedPhotoPath}` ; \
convert $resizedPhotoPath \
-gravity north -background '#0000' -font "Helvetica-Narrow-Bold" -pointsize 20 -fill black -size ${width}x caption:"${topCaption}" -composite \
-gravity north -background '#0000' -font "Helvetica-Narrow-Bold" -pointsize 20 -geometry +0-4 -fill white -size ${width}x caption:"${topCaption}" -composite \
-gravity south -background '#0000' -font "Helvetica-Narrow-Bold" -pointsize 20 -fill black -size ${width}x caption:"${bottomCaption}" -composite \
-gravity south -background '#0000' -font "Helvetica-Narrow-Bold" -pointsize 20 -geometry +0-4 -fill white -size ${width}x caption:"${bottomCaption}" -composite \
$photoPath
rm $resizedPhotoPath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment