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



