ImageExtract

public class ImageExtract

The class that allows you to get the size of a remote image without downloading.

  • A function to get the size of an image with preferred width and max height.

    Declaration

    Swift

    func extract(_ request: ImageRequestConvertible,
                        preferredWidth: CGFloat,
                        maxHeight: CGFloat = .greatestFiniteMagnitude) -> (size: CGSize, isFinished: Bool)

    Parameters

    request

    An image url to request. String, URL, and URLRequest are conform to ImageRequestConvertible protocol.

    preferredWidth

    A preferred width to resize.

    maxHeight

    A maximum height to be restricted at resizing.

    Return Value

    A tuple value including image size and task result. If the session is cancelled or fails to extract the size of an image, the value of isFinished will be false.

  • A function to get the size of an image with preferred width and max height.

    Declaration

    Swift

    func extract(_ request: ImageRequestConvertible,
                        preferredWidth: CGFloat,
                        maxHeight: CGFloat = .greatestFiniteMagnitude,
                        completion: @escaping (String?, CGSize, Bool) -> Void)

    Parameters

    request

    An image url to request. String, URL, and URLRequest are conform to ImageRequestConvertible protocol.

    preferredWidth

    A preferred width to resize.

    maxHeight

    A maximum height to be restricted at resizing.

    completion

    A handler that called when a request is completed. If the session is cancelled or fails to extract the size of an image, the value of isFinished will be false.

  • A Boolean value indicating whether download queues are running.

    Declaration

    Swift

    var isQueueRunning: Bool { get }
  • A Integer value indicating the number of running queues.

    Declaration

    Swift

    var queueCount: Int { get }
  • A function to cancel all running queues.

    Declaration

    Swift

    @discardableResult
    func cancelAllQueues() -> Bool

    Return Value

    A Boolean value indicating whether download queues are running.

  • A function to cancel a queue that contains a specific url.

    Declaration

    Swift

    @discardableResult
    func cancelQueue(request: ImageRequestConvertible) -> Bool

    Parameters

    request

    An image url to request. String, URL, and URLRequest are conform to ImageRequestConvertible protocol.

    Return Value

    A Boolean value indicating whether download queues are running.