How do I get the cropping frame of the address book image data?
Asked Answered
B

3

9

The AddressBook framework provides ABPersonCopyImageData for getting the contact image for each address book entry. This is great for the image data, but the user also sizes and crops the image for framing purposes. When I get the image data, I get the full image, and not the cropped image. How do I get the frame the user used to crop the image (or in lieu of that, how do I get access to the cropped image/data)?

Breach answered 10/7, 2010 at 17:32 Comment(0)
A
6

iOS 4.1 adds a new method: ABPersonCopyImageDataWithFormat in ABPerson.

I'm using it like this:

NSData *imageData = [(NSData *)ABPersonCopyImageDataWithFormat(recordRef, kABPersonImageFormatThumbnail) autorelease];

The formats allowed are:

kABPersonImageFormatThumbnail
kABPersonImageFormatOriginalSize

This allows you to get the original image or the cropped image (thumbnail).

Acarus answered 7/10, 2010 at 6:11 Comment(0)
B
1

To some extent, it's a bug in iOS4. Previously, the address book API returned cropped data, and in iOS4 it returns the whole image data. Some people want one, some people want the other. I tend to think the whole image data is useless without the cropping frame, so hopefully that will get fixed...

Breach answered 30/7, 2010 at 10:9 Comment(0)
W
0

I think it's impossible to get the crop rect. The crop rect information is stored inside the sqlite database that managed by addressbook framework. But client's application cannot read another application's sqlite database, according to the sandbox structure.

Williamwilliams answered 27/8, 2010 at 14:21 Comment(2)
Frameworks are not apps. "Sandboxing" is largely just process/UID-based. However, it turns out that /var/mobile/Library/AddressBook/AddressBookImages.sqlitedb is readable so it should be possible to get the crop rect out, even if it might be considered "private".Convulsive
If the sqlite database could be queried, then so many things can be solved. Something like custom labels, the crop rect problem here, and the store (ABStore) problem before iOS SDK 4.0, ... etc. My partner had tried and he said that it cannot execute commands on the sqlite database which managed by addressbook framework. Maybe you can try again.Williamwilliams

© 2022 - 2024 — McMap. All rights reserved.