Need to know which photo URLs are real

Marc RochkindMarc Rochkind Registered Users Posts: 21 Big grins
I have a so-called iPhone web app in which it's important to know whether a URL I am requesting (e.g., <something>-M.jpg) is real. It's not enough to have a photo delivered when I request the URL. For example, if the photo is smaller than medium, and I request a medium ("-M"), I do get a photo, but it is the original ("-O"). For most applications this makes no difference; a suitable image arrives in the browser and all is well. But, to exploit the ability of the iPhone (and similar devices) to cache images in its offline cache, so they can be viewed when the device is offline, the retrieved URL must match the requested URL exactly. No substitutes allowed!

It's easy I guess to do this for a particular gallery, but my web apps are built automatically by a tool, so I need an API way of doing it.

One way is to determine the original dimensions and then to try to emulate SmugMug's algorithms to try to figure out what is real and what is virtual.

The problem with this is that the behavior doesn't seem to be predictable. For example, I uploaded an image 410 wide by 256 high, and the only real sizes seem to be small and original. No medium even though the limit for small is 400 (or so I think).

What I want usually is one size that's iPhone-size or bigger (but no bigger than necessary, as it wastes space), and one that's iPad-size or bigger. I thought I could just ask for medium for the iPhone-size but, as I explained above, that doesn't work.

With sites like Flickr, where all the image URLs are real, this problem doesn't exist. (Of course, the chief downside to the Flickr approach is that once the URL is out, there is no protection, but that's a different issue entirely from the one that concerns me here.)

Thanks!

--Marc

Comments

  • hoffmcshoffmcs Registered Users Posts: 125 Major grins
    edited August 9, 2010
    I had to do something similar due to an issue with the redirects not being handled correctly and found that both dimensions must be over the threshold. For S, it is a 400 width and 300 height so your image falls into the small category due to its height. You can use the table on this page to determine the proper size based on dimension.
  • Marc RochkindMarc Rochkind Registered Users Posts: 21 Big grins
    edited August 10, 2010
    Actually, I think I have a solution: I get the headers for each candidate URL and take the ones that return 200, rejecting the redirects.

    --Marc
Sign In or Register to comment.