PHContentEditingInput

PHContentEditingInput

PHContentEditingInput Class of Photos A container that provides information about and access to the image, video, or Live Photo content of an asset to be edited.

class PHContentEditingInput

Overview

To edit an asset’s photo or video content:

  1. Fetch a `doc://com.apple.photokit/documentation/Photos/PHAsset` object that represents the photo or video to be edited.
  2. Call the asset’s `doc://com.apple.photokit/documentation/Photos/PHAsset/requestContentEditingInput(with:completionHandler:) method to retrieve a doc://com.apple.photokit/documentation/Photos/PHContentEditingInput` object.
  3. Apply your edits to the asset. To allow a user to continue working with the edit later (for example, to adjust the parameters of a photo filter), create a `doc://com.apple.photokit/documentation/Photos/PHAdjustmentData` object describing the changes.
  4. Initialize a `doc://com.apple.photokit/documentation/Photos/PHContentEditingOutput object. For photo- or video-only assets, use the editing output’s properties to provide edited asset data. For Live Photo assets, create a doc://com.apple.photokit/documentation/Photos/PHLivePhotoEditingContext` object to edit the Live Photo content.
  5. Use a photo library change block to commit the edit. In the block, create a `doc://com.apple.photokit/documentation/Photos/PHAssetChangeRequest object and set its doc://com.apple.photokit/documentation/Photos/PHAssetChangeRequest/contentEditingOutput property to the editing output that you created. For more details, see doc://com.apple.photokit/documentation/Photos/PHPhotoLibrary`.

You can also edit assets from photo editing extensions. In this case, instead of working with a PHAsset object, you implement methods in the PHContentEditingController protocol. Photos provides a PHContentEditingInput object when your extension begins editing. When editing is complete, Photos requests a PHContentEditingOutput object that contains the edited asset content.