PhotosGetSizes takes too long

Topics: User Forum
Mar 17, 2010 at 11:20 PM

Hi All,

I have PhotosGetSizes within a foreach loop and it takes about a minute for my application to display 50 photos. While it's extremely convenient to use PhotosGetSizes to findout which photo sizes I may download, that's far too much time spent on it, plus I can't really have it somewhere else other that the aforementioned foreach loop. Just wondering if anyone else has had a similar problem or figured out a workaround for it.

Thanks!

Coordinator
Mar 19, 2010 at 12:21 PM

The Flickr API imposes a rough limit of 1 query per second on developers. Obviously this is spread over a week, or even a month, so quick bursts are allowed.

I've tried calling PhotosGetSizes 50 times and it seems to take me about 10 seconds, so I'm surprised its taking you so long.

I've also just checked in a new change which allows you to request the image urls along with the search results:

 

PhotoSearchOptions o = new PhotoSearchOptions();
o.Extras = PhotoSearchExtras.AllUrls;
o.PerPage = 50;
o.Tags = "test";

PhotoCollection photos = f.PhotosSearch(o);

foreach(Photo p in photos)
{
  if( p.DoesLargeExist )
    Console.WriteLine(p.LargeUrl);
  else
    Console.WriteLine("Large image doesn't exist.");
  if( p.DoesMediumExist )
    Console.WriteLine(p.MediumUrl);
  else
   Console.WriteLine("Medium image doesn't exist.");
}

 

 

Mar 26, 2010 at 1:01 AM

Thanks for your reply. It is rather strange. The problem's obviously at my end. I've been trying to optimise my code as much as possible, haven't experienced any change in the delay yet. I'm going to try out the new version, see how it goes.

Apr 13, 2011 at 7:00 PM

Hey Sam,

DoesLargeExist always seems to return false despite there being a largeurl available for example with http://farm4.static.flickr.com/3439/3839665365_5c0cf64a86_b.jpg.

Is it a bug or am I missing something?

Thanx in advance.

Coordinator
Apr 15, 2011 at 10:01 AM

I think Flickr recently changed their criteria for when they generate a 'large' image (at the same time as they introduced the Medium 640 image size). However this is not a retrospective change as older photos of that size would not have a large image but newer ones will.

Your best bet is to always ask for the LargeUrl extra to be returned, then you will always get a truthful answer to the question.

Sam

Apr 15, 2011 at 11:54 PM
Edited Apr 15, 2011 at 11:55 PM

Thanks for the response Sam but I don't understand your suggestion.  What do you mean by "... ask for the LargeUrl extra to be returned..."?

Also, might we be fortunate enuf to see an update anytime soon that resolves this issue?  :D

/S

Coordinator
Apr 16, 2011 at 7:32 AM

As in the above example, you specify PhotoSearchExtras.AllUrls or PhotoSearchExtras.LargeUrl as part of your search, and then photo.LargeUrl will be returned by Flickr if it exists. The DoesLargeExist property always checks this value first and returns true if it exists.