Web Niraj
  • Facebook
  • Flickr
  • Github
  • Linkedin
  • Twitter
  • YouTube
Online portfolio, code examples and developer blog
  • About
  • Contact
  • Portfolio
  • WordPress
Search the site...
  • Home
  • Blog
  • Facebook API: Generating a Large Square Profile Image

Facebook API: Generating a Large Square Profile Image

3

With the introduction of Timeline users have larger profile images, but Facebook still restrict the “square” image to 50px by 50px. Here is a clever way of generating a new thumbnail image for the user (on the fly) using the Facebook Graph API and the PHP GD2 library (image manipulation).

The below code gets the image for a given ID from Facebook, and crops the image to what Facebook uses on the Timeline profile. The result is a square image in various dimensions. Some users will have a large square image (155px), while others might have a smaller one (75px).

You can call this script by pasting the code into a file (e.g. crop.php) and then navigating to: crop.php?id=60506094. Replace my Facebook ID with whatever you want to see the result.

Facebook, Facebook Graph API, GD2, Image Manipulation

3 comments on “Facebook API: Generating a Large Square Profile Image”

  1. Tomas says:
    November 29, 2012 at 5:40 AM

    i thought it is not possible to get bigger fb square icon than 50/50… you made my day! thank you very much for this post!!!

    Reply
  2. Mohammad says:
    January 5, 2013 at 11:47 PM

    I don’t get how I can navigate to crop.php?id=60506094? Do I open the php file in Firefox? Change the id parameters in the code to the required id?

    But thanks for the effort in providing this great method :D.

    Reply
    • Niraj Shah says:
      January 6, 2013 at 12:17 AM

      You need to upload the file to your server and then navigate to it via your site URL. Changing the ID in the URL will let to access a users profile image.

      Reply

Leave a Reply Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

StackExchange / StackOverflow

profile for Niraj Shah on Stack Exchange, a network of free, community-driven Q&A sites

PSN Profile

Tags

Amazon Web Services Android Android 4.4 KitKat Android 5.0 Lollipop Apache API Application Backup Bug Command Line Cordova Example Facebook Facebook Graph API Facebook PHP SDK 4.0 Facebook Social Plugins Fan Page Flash Geolocation Google Nexus 5 Google Nexus One Hacking HTML5 Image Manipulation iOS iPhone JavaScript jQuery Laravel 5 Linux NodeJS Parse PDF PHP Plugin Portfolio Review Security Server SSH SSL Sysadmin Tutorial WordPress WordPress Plugins
© 2011-2022 Niraj Shah
  • Blog
  • Portfolio
  • WordPress
  • About Me
  • Contact Me
  • Privacy Policy
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Privacy Policy