iOS Developer Library

Developer

AssetsLibrary Framework Reference ALAssetRepresentation Class Reference

Options
Deployment Target:

On This Page
Language:

ALAssetRepresentation

Inheritance


Conforms To


Import Statement


Swift

import AssetsLibrary

Objective-C

@import AssetsLibrary;

Availability


Available in iOS 4.0 and later.

An ALAssetRepresentation object encapsulates one of the representations of a given ALAsset object.

A given asset in the library may have more than one representation. For example, if a camera provides RAW and JPEG versions of an image, the resulting asset will have two representations—one for the RAW file and one for the JPEG file.

  • Returns a full resolution CGImage of the representation.

    Declaration

    Swift

    func CGImageWithOptions(_ options: [NSObject : AnyObject]!) -> Unmanaged<CGImage>!

    Objective-C

    - (CGImageRef)CGImageWithOptions:(NSDictionary *)options

    Parameters

    options

    A dictionary of options as described for CGImageSourceCreateWithData or CGImageSourceCreateWithURL.

    Return Value

    A full resolution CGImage of the representation.

    Discussion

    This method provides a convenient way to obtain a CGImage representation of an asset. This method returns the biggest, best representation available.

    Import Statement

    Objective-C

    @import AssetsLibrary;

    Swift

    import AssetsLibrary

    Availability

    Available in iOS 4.0 and later.

  • Returns a CGImage representation of the asset.

    Declaration

    Swift

    func fullResolutionImage() -> Unmanaged<CGImage>!

    Objective-C

    - (CGImageRef)fullResolutionImage

    Return Value

    A CGImage representation of the asset, or NULL if a CGImage representation could not be generated.

    Discussion

    This method returns the biggest, best representation available.

    To create a correctly-rotated UIImage object from the CGImage, you use imageWithCGImage:scale:orientation: or initWithCGImage:scale:orientation:, passing the values of orientation and scale.

    Import Statement

    Objective-C

    @import AssetsLibrary;

    Swift

    import AssetsLibrary

    Availability

    Available in iOS 4.0 and later.

  • Returns a CGImage of the representation that is appropriate for displaying full screen.

    Declaration

    Swift

    func fullScreenImage() -> Unmanaged<CGImage>!

    Objective-C

    - (CGImageRef)fullScreenImage

    Return Value

    A CGImage of the representation that is appropriate for displaying full screen, or NULL if a CGImage representation could not be generated.

    Discussion

    The dimensions of the image are dependent on the device your application is running on; the dimensions may not, however, exactly match the dimensions of the screen.

    In iOS 5 and later, this method returns a fully cropped, rotated, and adjusted image—exactly as a user would see in Photos or in the image picker.

    Import Statement

    Objective-C

    @import AssetsLibrary;

    Swift

    import AssetsLibrary

    Availability

    Available in iOS 4.0 and later.

  • Returns the representation’s orientation.

    Declaration

    Swift

    func orientation() -> ALAssetOrientation

    Objective-C

    - (ALAssetOrientation)orientation

    Return Value

    The representation’s orientation. For a list of possible values, see ALAssetOrientation.

    Import Statement

    Objective-C

    @import AssetsLibrary;

    Swift

    import AssetsLibrary

    Availability

    Available in iOS 4.0 and later.

  • Returns the representation’s scale.

    Declaration

    Swift

    func scale() -> Float

    Objective-C

    - (float)scale

    Return Value

    The representation’s scale.

    Import Statement

    Objective-C

    @import AssetsLibrary;

    Swift

    import AssetsLibrary

    Availability

    Available in iOS 4.0 and later.

  • Returns the representation’s dimensions.

    Declaration

    Swift

    func dimensions() -> CGSize

    Objective-C

    - (CGSize)dimensions

    Return Value

    The representation’s dimensions.

    Discussion

    If the representation doesn’t have valid dimensions, this method will return CGSizeZero.

    Import Statement

    Objective-C

    @import AssetsLibrary;

    Swift

    import AssetsLibrary

    Availability

    Available in iOS 5.1 and later.

  • Returns a string representing the filename of the representation on disk.

    Declaration

    Swift

    func filename() -> String!

    Objective-C

    - (NSString *)filename

    Return Value

    A string representing the filename of the representation on disk.

    Discussion

    For representations synced from iTunes, this will be the filename of the representation on the host.

    Import Statement

    Objective-C

    @import AssetsLibrary;

    Swift

    import AssetsLibrary

    Availability

    Available in iOS 5.0 and later.

  • Returns the size in bytes of the file for the representation.

    Declaration

    Swift

    func size() -> Int64

    Objective-C

    - (long long)size

    Return Value

    The size in bytes of the file for the representation.

    Discussion

    You typically use this method to allocate a buffer of the right size for getBytes:fromOffset:length:error:.

    Import Statement

    Objective-C

    @import AssetsLibrary;

    Swift

    import AssetsLibrary

    Availability

    Available in iOS 4.0 and later.

  • Copies a specified range of bytes into a given buffer.

    Declaration

    Swift

    func getBytes(_ buffer: UnsafeMutablePointer<UInt8>, fromOffset offset: Int64, length length: Int, error error: NSErrorPointer) -> Int

    Objective-C

    - (NSUInteger)getBytes:(uint8_t *)buffer fromOffset:(long long)offset length:(NSUInteger)length error:(NSError **)error

    Parameters

    buffer

    A buffer into which to copy the data.

    You typically use size to allocate a buffer of the right size.

    offset

    The number of bytes from the beginning of the file to start copying.

    length

    The number of bytes to copy.

    error

    If an error occurs, upon return contains an NSError object that describes the problem.

    Pass NULL if you do not want error information.

    Return Value

    The number of bytes actually written to buffer. The number of bytes read will be less than the requested range if the range exceeds the file's size. If an error occurs, returns 0.

    Discussion

    This method returns the biggest, best representation available.

    Import Statement

    Objective-C

    @import AssetsLibrary;

    Swift

    import AssetsLibrary

    Availability

    Available in iOS 4.0 and later.

    See Also

    – size

  • Returns the representation's UTI.

    Declaration

    Swift

    func UTI() -> String!

    Objective-C

    - (NSString *)UTI

    Return Value

    The representation's UTI

    Import Statement

    Objective-C

    @import AssetsLibrary;

    Swift

    import AssetsLibrary

    Availability

    Available in iOS 4.0 and later.

  • Returns a dictionary of dictionaries of metadata for the representation.

    Declaration

    Swift

    func metadata() -> [NSObject : AnyObject]!

    Objective-C

    - (NSDictionary *)metadata

    Return Value

    A dictionary of dictionaries of metadata for the representation. Returns nil if the representation is one that the system cannot interpret.

    Discussion

    The returned dictionary holds the same values that would be returned by CGImageSourceCopyPropertiesAtIndex.

    Import Statement

    Objective-C

    @import AssetsLibrary;

    Swift

    import AssetsLibrary

    Availability

    Available in iOS 4.0 and later.

  • Returns a persistent URL uniquely identifying the representation.

    Declaration

    Swift

    func url() -> NSURL!

    Objective-C

    - (NSURL *)url

    Return Value

    A persistent URL uniquely identifying the representation.

    Import Statement

    Objective-C

    @import AssetsLibrary;

    Swift

    import AssetsLibrary

    Availability

    Available in iOS 4.0 and later.