Facebook Graph API: Profile Pictures in Alternate Sizes

Now you can get custom sized images from the Facebook graph api. 

 

https://graph.facebook.com/cowholio4/picture

https://graph.facebook.com/cowholio4/picture?type=large

 

https://graph.facebook.com/cowholio4/picture?width=40

https://graph.facebook.com/cowholio4/picture?width=100&height=50

 

 

 

From the Facebook Blog:

In many cases, when displaying Facebook profile pictures, the image needs to fit into a specifically allotted space within the UI. Resizing and scaling the image can be a cumbersome process, often resulting in sub-optimal image quality.

 

This week, we released updates to our APIs to allow you to retrieve user's profile pictures in varying sizes. Alternate profile picture sizes can be queried via the Graph API and FQL.

 

To retrieve a profile picture in an alternate size via the Graph API, add the optional width and height fields as URL parameters:

 

https://graph.facebook.com/1207059/picture?width=121&height=100

 

This will return a HTTP 302 redirect to a profile picture with a minimum size of 121x100 while trying to preserve the aspect ratio. You can add the URL parameterredirect=false to retrieve just the URL to the pciture. If width=height then a square picture will always be returned.

 

You can also query for profile pictures of varying size using FQL:

 

SELECT url, real_width, real_height

FROM profile_pic

WHERE id=me()

AND width=121

AND height=100

 

Please see documentation for the Graph API User and Page objects, and the profile_pic for more information.

https://developers.facebook.com/blog/post/2012/08/22/platform-updates--operation-developer-love/