Getting image dimensions via API
jogle
Registered Users Posts: 422 Major grins
Is there a way to get the height and width of the re sized images via the API (1.2.2)?
I'm using javascript to pull a small or medium sized image and draw it to the page, but unless I can specify how large it is, I have to wait for it to load before continuing on with my script which resizes the iframe
smugmug.images.getInfo only returns the dimensions of the original image.
I'm using javascript to pull a small or medium sized image and draw it to the page, but unless I can specify how large it is, I have to wait for it to load before continuing on with my script which resizes the iframe
smugmug.images.getInfo only returns the dimensions of the original image.
jamesOgle photography
[FONT=Arial, Helvetica, sans-serif]"The single most important component of a camera is the twelve inches behind it." -A.Adams[/FONT]
0
Comments
We don't at the moment...but it sounds like something we can add for 1.2.3 and I think it will clean up the response format nicely.
Instead of this....
have something like this... Until that happens, giving that we always create the display sizes based on a fixed ratio for the longest side of the image....it should be pretty easy to calculate on the fly. I don't have those values easily accessible atm, I'll post in a bit.
Cheers,
David
SmugMug API Developer
My Photos
That was my thought to work out the ratio based on the longest edge. It would fall down in the case that the original is smaller then the display size but I could check for that first.
I've got a work around now that I've found I can resize the iframe each time I change the 'img src=' by using an 'img onload=' event in the same tag
Would you also add it to the method smugmug.images.getURLs? It seems like theres a bit of overlap between them and I've been thinking of switching to getURLs as it's a bit leaner.
I would find it a bit easier to parse the json response if it was a little more like this but I could work with it the way you propose if that's more like the other methods in the api
In this case, I would likely return it something like...
...
"ImageSizes": {
"Tiny": {"Size": "Tiny", "Height": "100", "Size": "..", "Width": "100", "URL": "http://fred.smugmug.com/photos/12345_nrBE6-Ti.jpg"},
"Thumb": {"Size": "Thumb", "Height": "150", "Size": "..", "Width": "150", "URL": "http://fred.smugmug.com/photos/12345_nrBE6-Th.jpg"},
...
And yes, this would apply to smugmug.images.getInfo, smugmug.images.get and smugmug.images.getURLs.
SmugMug API Developer
My Photos