Building a Photo Booth: Part III

So far (Part I, Part II) I set up my photo booth to take, edit, and combine images to form a photostrip. In order to share the pictures with friends and family, I wanted the photo booth to automatically upload the images to a social media site. I settled on using Flickr because it allows controlled access (pictures can be made private) and it has relatively user-friendly API. The API allows my photo booth software to automatically upload pictures as they are taken.

After a lot of sleuthing and tinkering, I found that this Python implementation of the Flickr API was my best bet. Once everything is set up with Flickr, the API allows you to upload images to your Flickr account with just a few lines of code.

Registering the photo booth with Flickr Before an application has access to any Flickr accounts, it must be registered through Flickr. You can follow the instructions here to register your application. The registration will give you a public and secret key that allow Flickr to authenticate your application. Keep these in a safe place.

Giving the photo booth access to your Flickr account In order to upload pictures to a Flickr account, you need grant the photo booth application access to your account. Here are some instructions on how to accomplish this. Be sure to set the permission ("perms") to "write" (instead of "read" as in the example).

Uploading Images In order to upload images to your Flickr account, you need to store the authentication keys associated with that account somewhere. Mine are stored in a file called “auth-handler” in the same directory as the python code for my photo booth. Here is the code used to upload an image to my Flickr account:

import flickr_api

flickr_api.set_keys(api_key = 'MY_KEY', api_secret = 'MY_SECRET')

flickr_api.set_auth_handler('auth-handler')  
user = flickr_api.test.login()

flickr_api.upload(photo_file = "/home/pi/photobooth/pics/tile.jpg", title = "Test Picture")  

After running this code, I looked at my Flickr photo stream and this is what I found.

So far everything seems to be working well! Next time, I will be putting together the hardware associated with my photo booth: flashing lights and buttons.

Will Rosenbaum

Tel Aviv

comments powered by Disqus