ImageExtract
public class ImageExtract
The class that allows you to get the size of a remote image without downloading.
-
A function to initialize instance.
Declaration
Swift
public init(userAgent: String? = nil, maxConnectionsPerHost: Int = 0, timeout: TimeInterval = 5, chunkSize: ImageChunkSize = .extraLarge)Parameters
userAgentA String value to be set in the request header.
maxConnectionsPerHostA Integer value that indicates the maximum number of simultaneous connections to make to a given host.
timeoutThe timeout interval to use when waiting for additional data.
chunkSizeChunk size limiting buffer size to be downloaded. The default value is ImageChunkSize.extraLarge. (50,000 bytes)
-
A function to get the size of a remote image synchronously.
Declaration
Swift
public func extract(_ request: ImageRequestConvertible) -> (size: CGSize, isFinished: Bool)Parameters
requestAn image url to request. String, URL, and URLRequest are conform to ImageRequestConvertible protocol.
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 a remote image asynchronously.
Declaration
Swift
public func extract(_ request: ImageRequestConvertible, completion: @escaping (String?, CGSize, Bool) -> Void)Parameters
requestAn image url to request. String, URL, and URLRequest are conform to ImageRequestConvertible protocol.
completionA 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 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
requestAn image url to request. String, URL, and URLRequest are conform to ImageRequestConvertible protocol.
preferredWidthA preferred width to resize.
maxHeightA 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
requestAn image url to request. String, URL, and URLRequest are conform to ImageRequestConvertible protocol.
preferredWidthA preferred width to resize.
maxHeightA maximum height to be restricted at resizing.
completionA 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() -> BoolReturn 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) -> BoolParameters
requestAn image url to request. String, URL, and URLRequest are conform to ImageRequestConvertible protocol.
Return Value
A Boolean value indicating whether download queues are running.