This project has moved and is read-only. For the latest updates, please go here.

How to obtain the height/width of a photo?

Sep 14, 2008 at 1:50 AM
Is there any way to obtain the height/width of a photo from the FlickrNet API? I need to decide if the photo is vertical or horizontal so I can render the web page correctly.$0$0$0$0Thanks!$0
Oct 2, 2008 at 2:36 PM
In the latest source you can request the OriginalHeight and OriginalWidth. These properties might not be available depending on the permissions of the user, but if you authenticate and request your own photos then they should be there.
Oct 21, 2008 at 9:24 AM

I'm trying to do the same thing as ycseattle. I've got the latest source but for some reason the OriginalHeight and OriginalWidthare coming back as -1.  Its for my personal website so I am authenticating using a saved token (as described in a few other posts).  Is there any reason the width and height would not come through.  My code is below:

            Flickr flickr = new Flickr(MyFlickrKeys.API,   MyFlickrKeys.Secret,  MyFlickrKeys.Token);
            flickr.AuthToken = MyFlickrKeys.Token;
            var options = new PhotoSearchOptions();
            options.UserId = MyFlickrKeys.UserId;
            options.PerPage = 100;
            Photos flickrPhotos = flickr.PhotosSearch(options);
            return flickrPhotos;

Thanks in advance
Oct 21, 2008 at 12:00 PM
You need to request them, as follows:
options.Extras = PhotoSearchExtra.OriginalFormat;
Hope that helps.
Oct 22, 2008 at 8:47 AM
Hi Sam,

Thanks for the quick response.  I tried options.Extras = PhotoSearchExtras.OriginalFormat and also options.Extras = PhotoSearchExtras.OriginalDimensions but the original width and height are still coming back as -1.  I wrote up a quick test app that where i authenticate everytime, rather than storing the token, still doesnt seem to be working.   Are the original dimensions always stored on Flickr.   Is there another way around my problem?  My test code is below.  Thanks again for your help. 

            Flickr flickr = new Flickr(FlickrKeys.API, FlickrKeys.Secret);

            string frob = flickr.AuthGetFrob();
            string url = flickr.AuthCalcUrl(frob, AuthLevel.Read);

            Console.WriteLine("Press Enter once authenticated");

            Auth auth = flickr.AuthGetToken(frob);
            flickr.AuthToken = auth.Token;

            var options = new PhotoSearchOptions();
            options.UserId = auth.User.UserId;
            options.PerPage = 100;
            options.PrivacyFilter = PrivacyFilter.CompletelyPrivate;
            options.Extras = PhotoSearchExtras.OriginalDimensions;
            Photos flickrPhotos = flickr.PhotosSearch(options);
             foreach (var photo in flickrPhotos.PhotoCollection)
                Console.WriteLine("Width = {0}", photo.OriginalWidth);
                Console.WriteLine("Height = {0}", photo.OriginalHeight);

Nov 3, 2008 at 12:24 PM
Hi Sam,

Any luck solving this problem? Is there another way around my problem?

Thanks again for all your help

Nov 5, 2008 at 4:16 PM
I've run test almost the same as your code above and it is successfully returning the original width and height.

Is the user who you authenticating against a Pro account holder? Original images are not available for none-Pro account holders.

Nov 10, 2008 at 10:21 AM
Hi Sam,

thanks for the reply.  I am not a Pro account holder, so this may be the problem. I might uprgrade.