Facebook Army ID Card Image Generator
Live Demo: http://apps.facebook.com/armyidcard/
The Idea
To explore what was possible using the Facebook Connect API, I decided to create a Army ID Card image generator. Users would either visit the Facebook application page or log-in via Facebook connect, then a JPEG image would be generated using their profile photo and details.Technology
The application uses two core technologies, Facebook Connect's API and the PHP GD library. User's information is requested from Facebook via the API, this includes their profile photo, name, age, and home town. The JPEG image is then generated by a process of laying multiple PNG images, TrueType font rendering and a series of colour filters. Within Facebook an application is created that ties all the technologies together and allows users to visit, bookmark and discuss the application.Code
The first task was to extract user information out of Facebook. Facebook helpfully provide a PHP library that ties into their API allowing for object-orientated access directly from your own application. Once I had setup a developer account with Facebook and generated the necessary API keys, accessing the gamut of user's data was relatively simple. With the user data to hand, the next step was to generate the image, this is where PHP GD came in.The idea was to start with a base image then add layers of text and imagery to create an authentic old looking Army ID card. I PhotoShopped a real World War II ID card, removing the photo and personal details. The coordinates for the photo location and text fields were recorded in preparation for later. Once I had a base background image, I began coding the PHP to load this image and then overlay the Facebook user's profile photo on top. It was then a process of adding additional layers on top, building up a composite image.Several colour filters are applied to both the user's profile photo and to the overall image, giving an old worn look. This was achieved using various PHP GD functions, allowed for a high level of customisation and visual tweaking.
The final stage was to export the image as a JPEG image and render it to the HTML via an IMG tag.