Friday, September 7, 2012

Downloading photos from flickr


I thought this might be helpful for people who want to download flickr images using api and can save them some time:
  1. Get an authentication key from flickr: http://www.flickr.com/services/api/misc.api_keys.html
  2. Install flickrapi: http://pypi.python.org/pypi/flickrapi 
    1. The easiest way to do this is using pip: 
      • sudo port install py32-pip(mac only, sudo apt-get install pip for linux?)
      • pip-3.2 install flickrapi ( depending on your pip version change the command.
  3. Run the attached python script with three command line arguments:
    1. Search query to retrieve photos of
    2. Number of photos
    3. Output directory to save to ( The sub-directory structure is similar to flickr's internal directory structure, You can modify the FlickrPhoto class to modify this behavior).
  4. This script uses the tag based search query. The code also has a way to use the search query instead of tag based query(commented out). All special arguments explained in the link for more information: http://www.flickr.com/services/api/flickr.photos.search.html
I copied/modified this code from a friend who in turn copied/modified it from an existing api tutorial. You do not have to cite either of us! :-)

NOTE: THIS CODE WILL NOT WORK UNTIL YOU FILL THE TWO KEYS INSIDE THE CODE. (LINE 47 and 48)

No comments: