简体   繁体   中英

Facebook Photo Size in iOS sdk

Right now with the Facebook iOS sdk, I am pulling images off the wall. but I need to analyze the photo and determine the height and width of the photo.

How would I go about doing this?

I know that this is an old question which has been answered, but since the accepted answer is very unclear and because this might help others that have the same problem as you had:

Given that the images that you pull off the wall are turned into UIImage objects before you display them, then you can just do the following to easily get the height and width of each object:

Full code example:

NSData* imageData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:yourimageurlhere]];
UIImage* image = [[[UIImage alloc] initWithData:imageData] autorelease];
[imageData release];

NSLog(@"Height : %0.1f", image.size.height);
NSLog(@"Width : %0.1f", image.size.width);

when you issue a call to GraphAPI photo object, you get dimensions in the response: https://graph.facebook.com/98423808305

is it what are you looking for?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM