SBSDKImageProcessor
@interface SBSDKImageProcessor : NSObject
A class to process images asynchronously: the heart of the Scanbot SDK image processing module. As image processing is most often consuming lots of memory this class processes images on a serial queue ensuring a minimum of large images in memory. Each operation reads the image from the imageURL, processes it and, if outputImageURL is a valid file URL, writes the result to outputImageURL. Upon completion completionHandler is called on main thread in a synchronous matter. After your completionHandler finished executing the next operation is enqueued. Its resultInfo dictionary contains the processed image, the source image URL and the destination image URL if specified.
-
Asynchronously applies one of the filters specified in SBSDKFilterType to the source image.
- SBSDKResultInfoDestinationImageKey: the output image as UIImage
Declaration
Objective-C
+ (nonnull SBSDKProgress *)filterImage:(nonnull UIImage *)image filter:(SBSDKImageFilterType)filter completion:(nullable SBSDKCompletionHandler) completionHandler;
Swift
class func filterImage(_ image: UIImage, filter: SBSDKImageFilterType, completion completionHandler: SBSDKCompletionHandler? = nil) -> SBSDKProgress
Parameters
image
The image to be filtered. Must not be nil.
filter
The filter to be applied on the input image.
completionHandler
The completionHandler that is being called upon completion of the operation. Called on main thread. The result info dictionary contains values for the following keys:
Return Value
An SBSDKProgress object that can be used to observe the operations progress and to cancel the operation.
-
Asynchronously rotates the source image clockwise 90 degrees * times.
- SBSDKResultInfoDestinationImageKey: the output image as UIImage
Declaration
Objective-C
+ (nonnull SBSDKProgress *)rotateImage:(nonnull UIImage *)image clockwise:(NSInteger)times completion:(nullable SBSDKCompletionHandler) completionHandler;
Swift
class func rotateImage(_ image: UIImage, clockwise times: Int, completion completionHandler: SBSDKCompletionHandler? = nil) -> SBSDKProgress
Parameters
image
The image to be filtered. Must not be nil.
times
The number of clockwise 90 degree rotations. Modulo arithmetic is applied internally.
completionHandler
The completionHandler that is being called upon completion of the operation. Called on main thread. The result info dictionary contains values for the following keys:
Return Value
An SBSDKProgress object that can be used to observe the operations progress and to cancel the operation.
-
Asynchronously rotates the source image counter clockwise 90 degrees * times.
- SBSDKResultInfoDestinationImageKey: the output image as UIImage
Declaration
Objective-C
+ (nonnull SBSDKProgress *)rotateImage:(nonnull UIImage *)image counterClockwise:(NSInteger)times completion:(nullable SBSDKCompletionHandler) completionHandler;
Swift
class func rotateImage(_ image: UIImage, counterClockwise times: Int, completion completionHandler: SBSDKCompletionHandler? = nil) -> SBSDKProgress
Parameters
image
The image to be filtered. Must not be nil.
times
The number of counter clockwise 90 degree rotations. Modulo arithmetic is applied internally.
completionHandler
The completionHandler that is being called upon completion of the operation. Called on main thread. The result info dictionary contains values for the following keys:
Return Value
An SBSDKProgress object that can be used to observe the operations progress and to cancel the operation.
-
Asynchronously applies a rotation of the given degrees to the source image.
- SBSDKResultInfoDestinationImageKey: the output image as UIImage
Declaration
Objective-C
+ (nonnull SBSDKProgress *)rotateImage:(nonnull UIImage *)image degrees:(CGFloat)degrees completion:(nullable SBSDKCompletionHandler) completionHandler;
Swift
class func rotateImage(_ image: UIImage, degrees: CGFloat, completion completionHandler: SBSDKCompletionHandler? = nil) -> SBSDKProgress
Parameters
image
The image to be filtered. Must not be nil.
degrees
The angle in degrees.
completionHandler
The completionHandler that is being called upon completion of the operation. Called on main thread. The result info dictionary contains values for the following keys:
Return Value
An SBSDKProgress object that can be used to observe the operations progress and to cancel the operation.
-
Asynchronously warps the source image into the given polygon. The final image is a perspective corrected and cropped version of the input image.
- SBSDKResultInfoDestinationImageKey: the output image as UIImage
Declaration
Objective-C
+ (nonnull SBSDKProgress *)warpImage:(nonnull UIImage *)image polygon:(nonnull SBSDKPolygon *)polygon completion:(nullable SBSDKCompletionHandler) completionHandler;
Swift
class func warpImage(_ image: UIImage, polygon: SBSDKPolygon, completion completionHandler: SBSDKCompletionHandler? = nil) -> SBSDKProgress
Parameters
image
The image to be warped. Must not be nil.
polygon
The polygon used to warp the image into. Must not be nil.
completionHandler
The completionHandler that is being called upon completion of the operation. Called on main thread. The result info dictionary contains values for the following keys:
Return Value
An SBSDKProgress object that can be used to observe the operations progress and to cancel the operation.
-
Asynchronously applies a custom filter to the source image.
- SBSDKResultInfoDestinationImageKey: the output image as UIImage
Declaration
Objective-C
+ (nullable SBSDKProgress *) customFilterImage:(nonnull UIImage *)image processingBlock:(nonnull SBSDKImageProcessingHandler)processingBlock completion:(nullable SBSDKCompletionHandler)completionHandler;
Swift
class func customFilterImage(_ image: UIImage, processingBlock: @escaping SBSDKImageProcessingHandler, completion completionHandler: SBSDKCompletionHandler? = nil) -> SBSDKProgress?
Parameters
image
The image to be filtered. Must not be nil.
processingBlock
The block that implements the filter. Must not be nil.
completionHandler
The completionHandler that is being called upon completion of the operation. Called on main thread. The result info dictionary contains values for the following keys:
Return Value
An SBSDKProgress object that can be used to observe the operations progress and to cancel the operation.
-
Asynchronously applies one of the filters specified in SBSDKFilterType to the image located at imageURL and saves the result to outputImageURL.
- SBSDKResultInfoSourceFileURLKey: imageURL as NSURL
- SBSDKResultInfoDestinationFileURLKey: outputImageURL as NSURL
- SBSDKResultInfoDestinationImageKey: the output image as UIImage
Declaration
Objective-C
+ (nonnull SBSDKProgress *)filterImage:(nonnull NSURL *)imageURL filter:(SBSDKImageFilterType)filter outputImageURL:(nullable NSURL *)outputImageURL completion:(nullable SBSDKCompletionHandler) completionHandler;
Swift
class func filterImage(_ imageURL: URL, filter: SBSDKImageFilterType, outputImageURL: URL?, completion completionHandler: SBSDKCompletionHandler? = nil) -> SBSDKProgress
Parameters
imageURL
The file URL of the image to be filtered. Must not be nil.
filter
The filter to be applied on the input image.
outputImageURL
The file URL to where the filtered image is written to. If nil no writing operation is performed.
completionHandler
The completionHandler that is being called upon completion of the operation. Called on main thread. The result info dictionary contains values for the following keys:
Return Value
An SBSDKProgress object that can be used to observe the operations progress and to cancel the operation.
-
Asynchronously rotates the image located at imageURL clockwise 90 degrees * times and saves the result to outputImageURL.
- SBSDKResultInfoSourceFileURLKey: imageURL as NSURL
- SBSDKResultInfoDestinationFileURLKey: outputImageURL as NSURL
- SBSDKResultInfoDestinationImageKey: the output image as UIImage
Declaration
Objective-C
+ (nonnull SBSDKProgress *)rotateImage:(nonnull NSURL *)imageURL clockwise:(NSInteger)times outputImageURL:(nullable NSURL *)outputImageURL completion:(nullable SBSDKCompletionHandler) completionHandler;
Swift
class func rotateImage(_ imageURL: URL, clockwise times: Int, outputImageURL: URL?, completion completionHandler: SBSDKCompletionHandler? = nil) -> SBSDKProgress
Parameters
imageURL
The file URL of the image to be filtered. Must not be nil.
times
The number of clockwise 90 degree rotations. Modulo arithmetic is applied internally.
outputImageURL
The file URL to where the filtered image is written to. If nil no writing operation is performed.
completionHandler
The completionHandler that is being called upon completion of the operation. Called on main thread. The result info dictionary contains values for the following keys:
Return Value
An SBSDKProgress object that can be used to observe the operations progress and to cancel the operation.
-
Asynchronously rotates the image located at imageURL counter-clockwise 90 degrees * times and saves the result to outputImageURL.
- SBSDKResultInfoSourceFileURLKey: imageURL as NSURL
- SBSDKResultInfoDestinationFileURLKey: outputImageURL as NSURL
- SBSDKResultInfoDestinationImageKey: the output image as UIImage
Declaration
Objective-C
+ (nonnull SBSDKProgress *)rotateImage:(nonnull NSURL *)imageURL counterClockwise:(NSInteger)times outputImageURL:(nullable NSURL *)outputImageURL completion:(nullable SBSDKCompletionHandler) completionHandler;
Swift
class func rotateImage(_ imageURL: URL, counterClockwise times: Int, outputImageURL: URL?, completion completionHandler: SBSDKCompletionHandler? = nil) -> SBSDKProgress
Parameters
imageURL
The file URL of the image to be filtered. Must not be nil.
times
The number of counter-clockwise 90 degree rotations. Modulo arithmetic is applied internally.
outputImageURL
The file URL to where the filtered image is written to. If nil no writing operation is performed.
completionHandler
The completionHandler that is being called upon completion of the operation. Called on main thread. The result info dictionary contains values for the following keys:
Return Value
An SBSDKProgress object that can be used to observe the operations progress and to cancel the operation.
-
Asynchronously applies a rotation of the given degrees to the image located at imageURL and saves the result to outputImageURL.
- SBSDKResultInfoSourceFileURLKey: imageURL as NSURL
- SBSDKResultInfoDestinationFileURLKey: outputImageURL as NSURL
- SBSDKResultInfoDestinationImageKey: the output image as UIImage
Declaration
Objective-C
+ (nonnull SBSDKProgress *)rotateImage:(nonnull NSURL *)imageURL degrees:(CGFloat)degrees outputImageURL:(nullable NSURL *)outputImageURL completion:(nullable SBSDKCompletionHandler) completionHandler;
Swift
class func rotateImage(_ imageURL: URL, degrees: CGFloat, outputImageURL: URL?, completion completionHandler: SBSDKCompletionHandler? = nil) -> SBSDKProgress
Parameters
imageURL
The file URL of the image to be filtered. Must not be nil.
degrees
The angle in degrees.
outputImageURL
The file URL to where the filtered image is written to. If nil no writing operation is performed.
completionHandler
The completionHandler that is being called upon completion of the operation. Called on main thread. The result info dictionary contains values for the following keys:
Return Value
An SBSDKProgress object that can be used to observe the operations progress and to cancel the operation.
-
Asynchronously warps the image located at imageURL into the given polygon and saves the result to outputImageURL. The final image is a perspective corrected and cropped version of the input image.
- SBSDKResultInfoSourceFileURLKey: imageURL as NSURL
- SBSDKResultInfoDestinationFileURLKey: outputImageURL as NSURL
- SBSDKResultInfoDestinationImageKey: the output image as UIImage
Declaration
Objective-C
+ (nonnull SBSDKProgress *)warpImage:(nonnull NSURL *)imageURL polygon:(nonnull SBSDKPolygon *)polygon outputImageURL:(nullable NSURL *)outputImageURL completion:(nullable SBSDKCompletionHandler) completionHandler;
Swift
class func warpImage(_ imageURL: URL, polygon: SBSDKPolygon, outputImageURL: URL?, completion completionHandler: SBSDKCompletionHandler? = nil) -> SBSDKProgress
Parameters
imageURL
The file URL of the image to be filtered. Must not be nil.
polygon
The polygon used to warp the image into. Must not be nil.
outputImageURL
The file URL to where the filtered image is written to. If nil no writing operation is performed.
completionHandler
The completionHandler that is being called upon completion of the operation. Called on main thread. The result info dictionary contains values for the following keys:
Return Value
An SBSDKProgress object that can be used to observe the operations progress and to cancel the operation.
-
Asynchronously applies a custom filter to the image located at imageURL and saves the result to outputImageURL.
- SBSDKResultInfoSourceFileURLKey: imageURL as NSURL
- SBSDKResultInfoDestinationFileURLKey: outputImageURL as NSURL
- SBSDKResultInfoDestinationImageKey: the output image as UIImage
Declaration
Objective-C
+ (nullable SBSDKProgress *) customFilterImage:(nonnull NSURL *)imageURL processingBlock:(nonnull SBSDKImageProcessingHandler)processingBlock outputImageURL:(nullable NSURL *)outputImageURL completion:(nullable SBSDKCompletionHandler)completionHandler;
Swift
class func customFilterImage(_ imageURL: URL, processingBlock: @escaping SBSDKImageProcessingHandler, outputImageURL: URL?, completion completionHandler: SBSDKCompletionHandler? = nil) -> SBSDKProgress?
Parameters
imageURL
The file URL of the image to be filtered. Must not be nil.
processingBlock
The block that implements the filter. Must not be nil.
outputImageURL
The file URL to where the filtered image is written to. If nil no writing operation is performed.
completionHandler
The completionHandler that is being called upon completion of the operation. Called on main thread. The result info dictionary contains values for the following keys:
Return Value
An SBSDKProgress object that can be used to observe the operations progress and to cancel the operation.