Facebook Graph API Profile Pictures in Alternate Sizes
This blog entry is archived. This means it's probably outdated.

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

Normal Photo
https://graph.facebook.com/cowholio4/picture
Large Photo
https://graph.facebook.com/cowholio4/picture?type=large
Specific Width (40px)
https://graph.facebook.com/cowholio4/picture?width=40
Specific Height and Width (100px x 50px)
https://graph.facebook.com/cowholio4/picture?height=100&width=50

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.