Archive for the ‘flickr’ Category

flickr API – How to get URL of a photo

Wednesday, December 28th, 2005

This task is not at all obvious from the documentation. However this documentation page will get you started.

As an example, here’s a Python function I wrote that works with the Photo object returned by flickr.py (a nice flickr API library for Python):

def getPhotoURL(photo,size='o'):
    """
    Create Photo URL as:

http://static.flickr.com/{server-id}/{id}_{secret}_[mstb].jpg

    Size Suffixes
    The letter suffixes are as follows:
    s   small square 75x75
    t   thumbnail, 100 on longest side
    m   small, 240 on longest side
    -   medium, 500 on longest side
    b   large, 1024 on longest side (only exists for very large original images)
    o   original image, either a jpg, gif or png, depending on source format
    """
    return r"""http://static.flickr.com/%s/%s_%s_%s.jpg""" % (str(photo.server),str(photo.id),str(photo.secret),size)

Thanks to J Wynia for the help.