CBLImageManipulationHelpers

Objective-C


@interface CBLImageManipulationHelpers : NSObject

Swift

class ImageManipulationHelpers : NSObject

Helper class for working with image data.

  • Rotates an image to orient it based on the given EXIF rotation value.

    Declaration

    Objective-C

    + (nullable NSData *)imageDataByRotatingImageData:(nonnull NSData *)sourceData
                                          forRotation:(CBLExifRotation)rotation;

    Swift

    class func imageData(byRotatingImageData sourceData: Data, for rotation: ExifRotation) -> Data?

    Parameters

    sourceData

    The source image data.

    rotation

    The EXIF rotation to apply to the image data.

    Return Value

    The rotated image, or nil if the given data wasn’t a valid image or an error occurred.

  • Crop the given thumbnail image based on the given metadata.

    Embedded thumbnails tend to be of a fixed size no matter the size and aspect ratio of the original image. This can result in black bars being encoded into the thumbnail image. This image will attempt to derive and perform a sensible crop based on the passed ImageIO metadata.

    Declaration

    Objective-C

    + (UIImage *_Nonnull)cropMetadatalessThumbnail:(nonnull CGImageRef)thumbnail
                                   basedOnMetadata:
                                       (nullable NSDictionary *)metadata;

    Swift

    class func cropMetadatalessThumbnail(_ thumbnail: CGImage, basedOnMetadata metadata: [AnyHashable : Any]?) -> UIImage

    Parameters

    thumbnail

    The thumbnail image to crop.

    metadata

    The metadata to derive the crop factor from.

    Return Value

    The cropped image.

  • Crop the given thumbnail image to the given aspect ratio.

    Declaration

    Objective-C

    + (UIImage *_Nonnull)cropMetadatalessThumbnail:(nonnull CGImageRef)image
                                toPreRotationRatio:(CGFloat)ratio;

    Swift

    class func cropMetadatalessThumbnail(_ image: CGImage, toPreRotationRatio ratio: CGFloat) -> UIImage

    Parameters

    image

    The image to crop.

    ratio

    The aspect ratio to crop to.

    Return Value

    The cropped image.