ImageResizer

public class ImageResizer

A class that can scale and resize images in a high-performant way

Init

  • Initialises a new ImageResizer instance with that loads the passed in image URL

    Throws

    Throws if there’s no existing file (that is also an image) at the passed URL or when the image properties could not be read

    Declaration

    Swift

    public init(sourceURL: URL) throws

    Parameters

    sourceURL

    The URL of the source image that is supposed to be resized or scaled

API

  • Resizes the loaded image

    Throws

    Throws if the image could not be resized correctly

    Declaration

    Swift

    public func resizeImage(to size: CGSize) throws -> CGImage

    Parameters

    size

    The desired target size of the resized image

    Return Value

    The resized image

  • Resizes the loaded image and writes it to the specified destination URL

    Throws

    Throws if the image could not be resized correctly or writing to the destination URL failed

    Declaration

    Swift

    public func resizeImage(to size: CGSize, destinationURL: URL, format: ImageFormat) throws

    Parameters

    size

    The desired target size of the resized image

    destinationURL

    The URL the resized image should be written to

    format

    The format that the resized image should be written in

  • Scales the loaded image by a factor

    Throws

    Throws if the image could not be scaled correctly

    Declaration

    Swift

    public func scaleImage(to scale: CGFloat) throws -> CGImage

    Parameters

    scale

    The desired relative scale of the scaled image

    Return Value

    The scaled image

  • Scales the loaded image and writes it to the specified destination URL

    Throws

    Throws if the image could not be scaled correctly or writing to the destination URL failed

    Declaration

    Swift

    public func scaleImage(to scale: CGFloat, destinationURL: URL, format: ImageFormat) throws

    Parameters

    scale

    The desired relative scale of the scaled image

    destinationURL

    The URL the scaled image should be written to

    format

    The format that the scaled image should be written in