Image crop and edit

Hello Apple Developer Community,

I'm excited to make my first post here and am seeking guidance for a feature I'd like to implement in my app. My objective is to enable users to select an image and crop it. Ideally, there should be a visible indicator, like a rectangle, to show the area that will be cropped. Upon clicking the save button, the image would be saved with the selected cropped area.

I'm aiming for functionality to the image editor in the Photos app. Is there a straightforward method or integration for this that adheres to Apple's native frameworks, without resorting to external GitLab repositories?

Thank you in advance for your assistance.

Best regards, Nicola

Replies

For the aspects of editing assets and saving them back to the photo library I'd point you to this page which details the Photos APIs you need for that: https://developer.apple.com/documentation/photokit/phasset/editing_asset_content

Another approach you could take would be to use the PhotosPicker to allow the user to select photos from their Photo Library and then you could just use the cropped images in your app or you could save them back as new assets to the library. I'd suggest you take a look at these APIs to see if they satisfy your app's needs: https://developer.apple.com/documentation/photokit/bringing_photos_picker_to_your_swiftui_app

For doing the actual cropping of the image you will likely want to use various Core Image APIs for that.