Class

PHImageManager

An object that facilitates retrieving or generating preview thumbnails and asset data.

Declaration

@interface PHImageManager : NSObject

Overview

Use these methods to fetch full-size photo assets or thumbnail images, or to retrieve AVFoundation objects for playing, exporting, and manipulating video assets.

To load image or video data:

  1. Use the PHAsset class to fetch the asset you’re interested in.

  2. Call the defaultManager method to retrieve the shared image manager object.

  3. Use one of the methods listed in Requesting Images and Requesting Video Objects to load the asset’s image or video data.

The image manager caches the asset images and data it provides, so later requests for the same assets with similar parameters will return results more quickly.

If you need to load image data for many assets together, use the PHCachingImageManager class to “preheat” the cache by loading images you expect to need soon. For example, when populating a collection view with photo asset thumbnails, you can cache images ahead of the current scroll position.

Topics

Getting the Image Manager

defaultManager

Returns the shared image manager object.

Requesting Images

requestImageForAsset:targetSize:contentMode:options:resultHandler:

Requests an image representation for the specified asset.

requestImageDataForAsset:options:resultHandler:

Requests full-sized image data for the specified asset.

PHImageManagerMaximumSize

A special value for requesting original image data or the largest rendered image available. .

Requesting Video Objects

requestPlayerItemForVideo:options:resultHandler:

Requests a representation of the video asset for playback, to be loaded asynchronously.

requestExportSessionForVideo:options:exportPreset:resultHandler:

Requests an export session for writing the video asset’s data to a file, to be loaded asynchronously.

requestAVAssetForVideo:options:resultHandler:

Requests AVFoundation objects representing the video asset’s content and state, to be loaded asynchronously.

Requesting Live Photos

requestLivePhotoForAsset:targetSize:contentMode:options:resultHandler:

Requests a Live Photo representation for the specified asset.

Canceling a Request

cancelImageRequest:

Cancels an asynchronous request

PHImageRequestID

A numeric identifier for an asynchronous image request.

PHInvalidImageRequestID

A special value provided for asynchronous image requests that cannot be canceled.

Constants

PHImageContentMode

Options for fitting an image’s aspect ratio to a requested size, used by the requestImageForAsset:targetSize:contentMode:options:resultHandler: method.

Image Result Info Keys

Keys identifying information about an image loading result, used in the resultHandler block with image request methods.

Relationships

Inherits From

See Also

Asset Loading

Loading and Caching Assets and Thumbnails

Request image, video, or Live Photos content, and cache for quick reuse.

PHCachingImageManager

An object that facilitates retrieving or generating preview thumbnails, optimized for batch preloading large numbers of assets.

PHImageRequestOptions

A set of options affecting the delivery of still image representations of Photos assets you request from an image manager.

PHVideoRequestOptions

A set of options affecting the delivery of video asset data that you request from an image manager.

PHLivePhotoRequestOptions

A set of options affecting the delivery of Live Photo assets you request from an image manager.