Flickr API Issues
Flickr.com offers a widely used API, that allows applications to access the stored photos and pictures. Despite the API is well documented, it still has quite a lot of mysteries - especially regarding the difference between Pro and Free members and photo access. This article tries to give missing information and describes workarounds.
Photo Formats on Flickr
When a photo is uploaded to flickr, it is saved in different versions:
- s small square 75x75 pixels
- t thumbnail, 100 pixels on longest side
- m small, 240 pixels on longest side
- - medium, 500 pixels on longest side
- b large, 1024 pixels on longest side (only exists for very large original images)
- o original image, either a jpg, gif or png, depending on source format, additionally protected by a original_secret (which means you cannot construct the source url without this code)
The letters refer to url suffixes that identify the photo. For more information see Flickr Photo Source URLs
This essentially means that you can only download the original size version of an image if:
- the publisher of the image has a flickr pro account
- he granted you download rights (see below)
it doesn't matter if the downloader has a flickr free or a pro account
Permissions for photo access
The flickr user who uploaded the picture specifies the rules for photo access. He can set the visibility of the picture (private/friends only/public)on a per-photo basis. The download rights can only be set globally via Your Account -> Privacy & Permissions -> Allowing Downloads:
- There are 5 permission levels: only me, friends&family, flickr contracts, flickr users (logged in), anyone (anonymous access)
- If a user has no rights to download, the photo is only visible at a low-res-resolution in the photo stream of the user, the 'All Sizes'-page is not available.
- There is one exception to the global download rule: if you change the license of a picture from All rights reserved to some Creative-Commons License, then this picture is available for download.
- Only Pro users can offer the download of original size images.
Setting Flickr Download Permissions
Special Photo Format Issues
However, there are two important issues with large and original size format:
- Large format is only generated if the uploaded picture exceeds 1280 Pixels on the longest side.
- If no Large format was generated, the Original Format is offered for download at the photopage, EVEN if the publisher has just a free account. Unfortunately, the flickr API is unaware of this exception and doesn't return the required original_secret/format for constructing the photo source url.
Consequences for picurl
Our goal is to download the highest-possible resolution of a flickr image, no matter if the publisher is a free or pro user. However, our second goal is efficiency. We don't want to do unnecessary API calls that slow down picurl when indexing a flickr store.
Therefore I will propose here an improved algorithm for constructing flickr download urls:
- Auto-Login the downloader. Auto-Login means that if there is a flickr token file stored on the user's disk, he is authenticated automatically. If not, he will remain anonymous. As many pro users restrict downloading to their friends/contacts, this can improve the access to high-res images.
- Determine the account type of the image publisher.
- Conduct an photostream/photoset search (depending on user input).
- if the publisher has a pro account and the search response contains original_format/original_secret, then construct the original size url.
- if the publisher has a pro account and the search response doesn't contain original_format/original_secret, the user has no download rights. We can only offer the default 500x375 low res image in this case.
- if the publisher has a free account, we will first construct a 'large-format' url (_b suffix). If the retrieval of this url fails, we can user FlickrHelper to retrieve the URL of the original_format.
