My little photobooth app for Linux

(Here’s yet another Linux entry that I’m posting to remind me of what I’ve done to solve a problem. If you’re a regular reader of my sermon blog, this entry might not make sense to you.)

outputEvery year our church hosts a Harvest Carnival for the neighborhood children on whichever Sunday night is closest to Halloween. We have a sit down meal for families, lots of carnival games, and more than enough candy to send any twelve diabetics into a coma. Fun times.

One of the events we offer is a photo booth, where the kids come and strike cheesy poses in their costumes, and then they get a photo strip for a souvenir. To RENT a photo booth that does this is expensive, and besides – we already OWN a computer and a printer. It must be a simple matter to set it up to fulfill that function, right?

Yes. So simple, in fact, that I forget to save the work that I’ve done on this year after year. I end up hacking this together FROM SCRATCH every year. No more. I’m saving my work here for future reference.

Since I use Linux, it’s a matter of gathering the tools, and figuring out how to chain them together to make them do what I want: to result in this filmstrip format shown here. That means I have to make sure I have the physical equipment as well as the software. Here’s the shopping list, as it were:

  • computer (using the church laptop)
  • printer (I normally use the color laser printer, but it wasn’t working: enter a cheap HP inkjet)
  • bright light (an old overhead projector works well here)
  • webcam (Logitech USB, not the one on the laptop)

And then there’s the software to pull it all together:

  • Cheese (webcam software)
  • ImageMagick (to manipulate the images taken)
  • gtkdialog (an old school graphic user interface scripting tool – to make it all pretty)

Now that I’ve got all those tools installed, I write three scripts to make them dance. The main script that does the work I call “mycheesyphotoboothscript”:

#!/bin/sh
mv ~/Pictures/Webcam/*.jpg ~/Pictures/Webcam/2016backup
mv ~/Pictures/Webcam/*.png ~/Pictures/Webcam/2016backup
cheese
cd ~/Pictures/Webcam/
convert 2016*.jpg[400x400] -splice 0x10 -background "#ffffff" -append -crop -0+10 output.png
lpr -o fit-to-page -PHP_ENVY_4520 output.png

All of the photographs taken by Cheese are placed in the Pictures/Webcam subdirectory of my Home. So, the first two lines move any existing photos to a backup directory (~/Pictures/Webcam/2016backup).

Next, the Chesse program is started. I then aim the camera, turn on the lights, make funny faces to get good shots… and when I have three or four good shots, I **close** the Cheese program. That tells the script to do the NEXT commands, which is to move into the Pictures/Webcam directory.

Next, we CONVERT the existing pictures just taken into a single vertical strip named “output.png”.

Finally, we send that file to the printer with the LPR command, making sure it fits on the page.

When I use this program next year, I’ll have to change the printer name from HP_ENVY_4520 to whatever printer I’m using.

The other scripts are really just for housekeeping/ease of use. I create a pretty launcher script called “PhotoBooth”:

#! /bin/bash

export MAIN_DIALOG='
<window title="PictureBooth-O-Matic" icon-name="gtk-preferences" resizable="true" decorated="true">
 <vbox>
 <hbox>
 <vbox>
 <hbox>
 <button>
 <label>"Cheese"</label>
 <input file>"/usr/share/icons/Moka/64x64/apps/cheese.png"</input>
 <action>mycheesyphotoboothscript</action>
 </button>
 </hbox>
 </vbox>
 <vbox>
 <hbox>
 <button>
 <label>"Close"</label>
 <input file>"/usr/share/icons/Moka/64x64/actions/exit.png"</input>
 <action>EXIT:close</action>
 </button>
 </hbox>
 </vbox>
 </hbox>
 </vbox>
</window>
'
gtkdialog --program MAIN_DIALOG

Which gives me this: cheezy

And finally, to make sure I can FIND the program, I write a little launcher that makes it show up in my menus. In Linuxland, we call these .desktop files, and here’s the PhotoBooth.desktop file:

[Desktop Entry]
Name=Cheezy PhotoBooth
Comment=create photo booth strips
Exec=/home/ed/Programs/MyBinaries/PhotoBooth
Icon=/home/ed/.local/share/icons/Moka/64x64/apps/cheese.png
Terminal=false
Type=Application
Categories=Graphics;
StartupNotify=true
MimeType=application/x-ms-dos-executable
NoDisplay=false

Hope that helps someone (and reminds me to NOT erase all this work so I don’t have to do this from scratch next year).

Advertisements

0 Responses to “My little photobooth app for Linux”



  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




Pastor Ed Backell

Flickr Photos

Pastoral Tweets

  • Check out this photo of Pho Yelm Restaurant on #Yelp yelp.com/biz_photos/pho… 1 day ago
  • How Does God Show Us He Loves Us? God Brings Us Into His Family (Romans 8:14-16) 3 days ago
  • God chooses US, just like He chose Jacob. He calls us His own; we belong to God, and there’s nothing we can do to break God’s promise to us. 3 days ago
  • How Does God Show Us He Loves Us? God’s Plans Change Us (Genesis 28:16-19) 3 days ago
  • How Does God Show Us He Loves Us? God Has Plans For Us (Genesis 28:10-15) 3 days ago

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 774 other followers


%d bloggers like this: