capacitor-community / contacts

Contacts Plugin for Capacitor
https://capacitor-community.github.io/contacts/
119 stars 52 forks source link

iOS Contact Image not cropped #108

Closed scriptPilot closed 1 year ago

scriptPilot commented 1 year ago

Describe the bug When adding a contact photo via iOS Contacts and crop the face from a large image, the large image is retrieved not only the cropped face as expected.

To Reproduce Steps to reproduce the behavior:

  1. Create a new contact in iOS Contacts
  2. Choose a lager image
  3. Crop a face
  4. Save
  5. Retrieve contact with this API

Expected behavior Cropped image / face retrieved as base64 string.

Screenshots n/a

Smartphone (please complete the following information):

Additional context

tafelnl commented 1 year ago

The CNContactStore in Swift provides the following two image types:

CNContactImageDataKey and CNContactThumbnailImageDataKey.

Currently it's returning the value belonging to the CNContactImageDataKey. I'm not sure if the CNContactThumbnailImageDataKey would return a 'cropped' variant. It would return a thumbnail though. So I'm not sure if that is desirable. What do you think?

If you have access to Xcode, you could easily test the difference between to two by the way. Just navigate to the source code and swap:

scriptPilot commented 1 year ago

@tafelnl - Thanks a lot for that proposal. I've just tested it and the images are still returned full, not cropped, but in poorer quality. So this proposal does not solve the initial problem unfortunately.

tafelnl commented 1 year ago

In that case I am afraid it's not possibly to do what you want. Because Apple does not offer any other thing in their CNContact API that I know of

scriptPilot commented 1 year ago

Ok - thanks for looking into it.

tafelnl commented 1 year ago

No worries