Getting the cropped version of a picture from the address book

891 Views Asked by At

I load a contacts picture from the address book using the following code:

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier{

    UIImage *image = [UIImage imageWithData:(NSData *)ABPersonCopyImageData(person)];

    return NO;
}

However, this code returns the full image that is stored rather than the cropped version, that is shown in various places, like the Addressbook.

1

There are 1 best solutions below

0
On BEST ANSWER

I found the answer here: https://stackoverflow.com/a/6953492/784318

NSData *imageData = (__bridge NSData*)ABPersonCopyImageDataWithFormat(person, kABPersonImageFormatThumbnail);
UIImage *image = [UIImage imageWithData:imageData];