Facebook introduced a way for developers to retrieve users’ profile pictures for use within their applications in different sizes, rather than resizing and scaling them into a standard space.
The social network explained the details in a post on its developer blog:
In many cases, when displaying Facebook profile pictures, the image needs to fit into a specifically allotted space within the user interface. Resizing and scaling the image can be a cumbersome process, often resulting in suboptimal image quality.
This week, we released updates to our application-programming interfaces to allow you to retrieve users’ 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 121×100 while trying to preserve the aspect ratio. You can add the URL parameter redirect=false to retrieve just the URL to the picture. 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
- (try this query)
Please see documentation for the graph API user and page objects, and the profile pic, for more information.
Image courtesy of Shutterstock.
