Class

PHContentEditingOutput

A container to which you provide the results of editing the photo, video, or Live Photo content of a Photos asset.

Declaration

@interface PHContentEditingOutput : NSObject

Overview

To edit an asset’s photo or video content:

  1. Fetch a PHAsset object that represents the photo or video to be edited.

  2. Call the asset’s requestContentEditingInputWithOptions:completionHandler: method to retrieve a PHContentEditingInput object. This object provides information about the asset, the asset data to be edited, and a preview image for display.

  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 PHAdjustmentData object describing the changes.

  4. Initialize a PHContentEditingOutput object. For photo- or video-only assets, provide the edited content with the renderedContentURL property. For Live Photo assets, create a PHLivePhotoEditingContext object to edit the Live Photo content and pass your content editing output to the saveLivePhotoToOutput:options:completionHandler: method.

    For all asset types, provide your adjustment data with the adjustmentData property of the content editing output.

  5. Use a photo library change block to commit the edit. (For details, see PHPhotoLibrary.) In the block, create a PHAssetChangeRequest object and set its contentEditingOutput property to the editing output that you created.

    Each PHPhotoLibraryperformChanges call prompts the user for permission to edit the contents of the photo library—to edit multiple assets in one batch, create multiple PHAssetChangeRequest objects within the same change block, each with its own corresponding PHContentEditingOutput object.

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 PHContentEditingOutput object when your extension begins editing. When editing is complete, Photos requests a PHContentEditingOutput object that contains the edited asset content.

Topics

Creating an Output Object to Edit an Existing Asset

- initWithContentEditingInput:

Creates an editing output from the specified editing input.

Creating an Output Object to Edit a Newly Created Asset

- initWithPlaceholderForCreatedAsset:

Creates an editing output for use in adding a new asset to the photo library.

Providing Edit and Adjustment Data

adjustmentData

An object describing the changes made to the asset.

renderedContentURL

The URL at which to write a file containing edited asset content.

Relationships

Inherits From

See Also

Editing an Asset

Editing Asset Content

Make a request to modify and save a photo or video asset.

PHContentEditingInput

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

PHAdjustmentData

A description of the edits made to an asset's photo, video, or Live Photo content, which allows your app to reconstruct or revert the effects of prior editing sessions.

PHContentEditingInputRequestOptions

A set of options affecting the delivery of image or video data when you request to edit the content of a Photos asset.

PHLivePhotoEditingContext

An editing session for modifying the photo, video, and audio content of a Live Photo.

PHLivePhotoFrame

A container that provides image content for a single frame of a Live Photo in an editing context.

- canPerformEditOperation:

Returns whether the asset supports the specified editing operation.

PHAssetEditOperation

Values identifying possible actions an asset can support, used by the canPerformEditOperation: method.

- requestContentEditingInputWithOptions:completionHandler:

Requests asset information for beginning a content editing session.

- cancelContentEditingInputRequest:

Cancels a request for editing the asset’s content.

PHContentEditingInputRequestID

An identifier for an asset content editing session.

Editing Request Info Keys

Keys indicating the status of an asset content editing request, used in the completion handler of the requestContentEditingInputWithOptions:completionHandler: method.