In the beginning

The first available function was ABPersonCopyImageData ( ABRecordRef person ) which, until iOS 3.2, returned an object with the picture as defined by the user, ie the original picture including cropping. But, starting iOS 4.0, this function now returns the “raw” version of the picture, without cropping.

The new way to do

Starting iOS 4.1, a new function ABPersonCopyImageDataWithFormat ( ABRecordRef person, ABPersonImageFormat format ) is available. This function, very similar to the previous one, accepts a new parameter which can have the following values:

  • kABPersonImageFormatThumbnail : the returned object represents the picture of the contact as defined in the address book (same behavior than ABPersonCopyImageData before iOS 4.0).
  • kABPersonImageFormatOriginalSize : the returned object represents the raw picture from which is derived the picture in the address book.

Known issue

The problem with this new function is that it's available only starting iOS 4.1. Apps using iOS 4.0.x will have to use original function, but with a wrong behavior compared to previous releases of iOS. You just have to hope that the devices using iOS 4.0 will be a minority.

The code

In order to properly handle different versions of iOS, here's an example of a function fetching the picture of a contact

// Return picture from contact
- (UIImage *) contactPicture:(NSInteger)contactId {
    // Get contact from Address Book
    ABAddressBookRef addressBook = ABAddressBookCreate();
    ABRecordID recordId = (ABRecordID)[contactId intValue];
    ABRecordRef person = ABAddressBookGetPersonWithRecordID(addressBook, recordId);
    // Check for contact picture
    if (person != nil && ABPersonHasImageData(person)) {
        if ( &ABPersonCopyImageDataWithFormat != nil ) {
            // iOS >= 4.1
            return [UIImage imageWithData:(NSData *)ABPersonCopyImageDataWithFormat(person, kABPersonImageFormatThumbnail)];
        } else {
            // iOS < 4.1
            return [UIImage imageWithData:(NSData *)ABPersonCopyImageData(person)];
    } else {
        return nil;

All behaviors in a single picture

Photo contact