Uploading photos to Shutterfly via Python
I finally got done sorting my 2008 photos this morning so I can start putting Christmas gifts together with them and needed to upload about 280 pictures to Shutterfly, where I have been getting prints since about 1999. Of course I could do this with their uploader, but that would be quite lame now, wouldn’t it, considering I could use Python to do it. Using the code below, the IPTCInfo module and Jeremy Slater’s very cool shutterfly module he wrote for the GNOME Conduit Project , I can iterate through my entire 2008 photo directory, look for my photos tagged for upload, and upload them to a specific album on Shutterfly. Sweet!
from IPTC import IPTCInfoimport sys, os, shutterflyclass ShutterflyUploadr:def __init__(self):passdef grab_new_images( self ):""" Recurses thru directories and looks for images to upload. I only want to upload my '5-star' images, so we scan the IPTC tags for 'r5', my way of tagging my pics I really like (usually get prints of r5s) """images = []for dirpath, dirnames, filenames in os.walk('/users/chad/pictures/2008'):for f in filenames :# Grab IPTC keywordsinfo = IPTCInfo(os.path.join(dirpath, f))# Is it a 5-star photo?if 'r5' in info.keywords:ext = f.lower().split(".")[-1]if ( ext == "jpg" ):images.append( os.path.normpath( dirpath + "/" + f ) )images.sort()return imagesdef upload( self ):""" Upload images to Shutterfly """user = 'your_user_name'pwd = 'your_password'sfly = shutterfly.Shutterfly(user,pwd)# Get an existing albumalbum = sfly.getAlbums()['Album_Name']image_list = self.grab_new_images()for image in image_list:album.uploadPhoto(image, 'image/jpeg', os.path.basename(image))if __name__ == '__main__':sfu = ShutterflyUploadr()sfu.upload()- Download this code: shutterflyuploadr.txt



Can you make a PHP version of this code? That will be really helpful.
@Riz: Sorry, I don’t do that much PHP. And besides, Python is so much more elegant and efficient.
Hey there,
Have there been any changes to this code? I’ve been wracking my brains trying to get it to upload. See here: http://stackoverflow.com/questions/2785496/a-python-wrapper-for-shutterfly-uploading-an-image
And shuttefly tells me there was no image on the upload.
Any insights into how to use python to get it to correctly upload would save my life.
Thanks!