Class

PHContentEditingInput

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

Declaration

class PHContentEditingInput : 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 requestContentEditingInput(with:completionHandler:) method to retrieve a 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 PHAdjustmentData object describing the changes.

  4. Initialize a 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 PHLivePhotoEditingContext object to edit the Live Photo content.

  5. Use a photo library change block to commit the edit. In the block, create a PHAssetChangeRequest object and set its contentEditingOutput property to the editing output that you created. For more details, see 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.

Topics

Getting Information About the Asset

var mediaType: PHAssetMediaType

The type of the asset, such as video or audio.

enum PHAssetMediaType

Constants identifying the general type of an asset, such as image or video.

var mediaSubtypes: PHAssetMediaSubtype

The subtypes of the asset, identifying special kinds of assets such as a panoramic photo or a high-frame-rate video.

struct PHAssetMediaSubtype

Constants identifying specific variations of asset media, such as panorama or screenshot photos and time lapse or high frame rate video.

var creationDate: Date?

The date and time when the asset was originally created.

var location: CLLocation?

The location information that was saved with the asset.

var uniformTypeIdentifier: String?

The uniform type identifier for the asset’s image or video data.

Working with Previous Edits

var adjustmentData: PHAdjustmentData?

An object that describes the most recent edit to the asset’s content.

Working with Photo Assets

var displaySizeImage: UIImage?

An image of the asset’s contents, appropriately sized for display.

var fullSizeImageOrientation: Int32

The Exif display orientation of the full-size image file.

var fullSizeImageURL: URL?

The URL to a file that contains the full-sized image data.

Working with Video Assets

var audiovisualAsset: AVAsset?

The video asset, as an AVAsset object.

var avAsset: AVAsset?

The video asset, as an AVAsset object.

Deprecated

Working with Live Photo Assets

var livePhoto: PHLivePhoto?

The unedited Live Photo content of the editing input.

Relationships

Inherits From

Conforms To

See Also

Editing an Asset

Editing Asset Content

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

class PHContentEditingOutput

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

class 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.

class PHContentEditingInputRequestOptions

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

class PHLivePhotoEditingContext

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

protocol PHLivePhotoFrame

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

func canPerform(PHAssetEditOperation) -> Bool

Returns whether the asset supports the specified editing operation.

enum PHAssetEditOperation

Values identifying possible actions an asset can support, used by the canPerform(_:) method.

func cancelContentEditingInputRequest(PHContentEditingInputRequestID)

Cancels a request for editing the asset’s content.

typealias 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 requestContentEditingInput(with:completionHandler:) method.