Class

PHLivePhotoEditingContext

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

Declaration

@interface PHLivePhotoEditingContext : NSObject

Overview

A Live Photo is a picture, captured by a supported iOS device, that includes motion and sound from the moments just before and after it was taken. Editing the content of a Live Photo works much like editing other asset types:

  1. In an app using the Photos framework, fetch a PHAsset object that represents the Live Photo to edit, and use that object’s requestContentEditingInputWithOptions:completionHandler: method to retrieve a PHContentEditingInput object.

    In a photo editing extension that runs within the Photos app, your extension’s main view controller (which adopts the PHContentEditingController protocol) receives a PHContentEditingInput object when the user chooses to edit a Live Photo with your extension.

  2. Create a Live Photo editing context with the initWithLivePhotoEditingInput: initializer.

    You can create a Live Photo editing context only from PHContentEditingInput object that represents a Live Photo. Use the livePhoto property of the editing input to verify that it has live Photo content.

  3. Use the frameProcessor property to define a block to be used in processing the Live Photo’s visual content. Photos will call this block repeatedly to process each frame of the Live Photo’s video and still photo content.

  4. Create a PHContentEditingOutput object to store the results of your edit, then call the saveLivePhotoToOutput:options:completionHandler: to process the Live Photo and save it to your editing output object. This method applies your frameProcessor to each frame.

  5. To allow a user to continue working with the edit later (for example, to adjust the parameters of a filter), create a PHAdjustmentData object describing your changes, and store it in the adjustmentData property of your editing output.

  6. In an app using the Photos framework, 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.

    In a photo editing extension, provide the PHContentEditingOutput object that you created in your main view controller’s finishContentEditingWithCompletionHandler: method.

When you use either of the methods listed in Processing an Editing Context’s Live Photo, Photos calls your frameProcessor block repeatedly to process each frame of the Live Photo’s video and still photo content. In that block, a PHLivePhotoFrame object provides the Live Photo’s existing content as a CIImage object. You use Core Image to modify the image, then provide the result of your edits by returning a CIImage object representing the result of processing the input image.

Topics

Creating a Live Photo Editing Context

- initWithLivePhotoEditingInput:

Creates a Live Photo editing context for the specified editing input.

Preparing an Editing Context for Processing

frameProcessor

A block to be called by Photos for processing each frame of the Live Photo’s visual content.

PHLivePhotoFrameProcessingBlock

The signature for a block Photos calls to process Live Photo frames.

audioVolume

The audio gain to apply to the processed Live Photo.

Processing an Editing Context’s Live Photo

- saveLivePhotoToOutput:options:completionHandler:

Processes and saves a full-quality Live Photo as the output of your editing session.

- prepareLivePhotoForPlaybackWithTargetSize:options:completionHandler:

Processes a Live Photo with your edits for viewing.

PHLivePhotoEditingOption

Keys for the options dictionary used with the methods listed in Processing an Editing Context’s Live Photo.

- cancel

Aborts any Live Photo processing in progress.

Examining an Editing Context’s Live Photo

fullSizeImage

The unedited still photo content of the Live Photo.

duration

The duration, in seconds, of the Live Photo.

photoTime

The offset, in seconds, from the beginning of the Live Photo’s duration to the time corresponding to its still photo.

orientation

The image orientation of the Live Photo.

Errors

PHLivePhotoEditingErrorDomain

The domain value for error objects produced by a Live Photo editing context.

Deprecated
PHLivePhotoEditingErrorCode

Error codes for Live Photo editing errors.

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.

PHContentEditingOutput

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

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.

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.