sveti petar
sveti petar

Reputation: 3797

Facebook graph API - get custom profile picture size

I'm trying to get the logged in user's profile picture for a canvas app, but I would like to have it in a specific size.

Is this possible and, if so, how?

Currently I'm using the following:

graph.facebook.com/{user's FB ID}/picture?type=square

This gives me a 50px by 50px image. There are also options to use type=normal and type=large to give large image size, but these are not square images, and also not the exact size I am looking for.

To be specific, is there a way to get a member's profile picture in size 80px by 80px directly from Facebook, without downloading a larger image and downsizing/cropping on my end?

Upvotes: 17

Views: 24339

Answers (3)

user6221709
user6221709

Reputation:

Getting a bigger facebook profile picture via facebook php sdk, this worked for me:

$response = $fb->get('/me?fields=picture.width(400).height(400)', getenv('FACEBOOK_ACCESS_TOKEN'));

in 2019!

Upvotes: 12

Julian
Julian

Reputation: 69

https://graph.facebook.com/[[[[insertusersfbid]]]]/picture?type=large Is what i fall back to... https://graph.facebook.com/[[[[insertusersfbid]]]]/picture?width=2000&height=2000 Is when i want to muck with the image. If the user does not have an uploaded profilepicture; now fb returns the gender based default pic... I hope this helps someone else :)

Upvotes: 2

andyrandy
andyrandy

Reputation: 73984

You can use width/height as parameter:

graph.facebook.com/{user's FB ID}/picture?width=100&height=100

Just keep in mind that you may not get exact sizes, but very close ones.

Upvotes: 36

Related Questions