lanczosScaleTransform()
Creates a high-quality, scaled version of a source image.
Declaration
class func lanczosScaleTransform() -> any CIFilter & CILanczosScaleTransformMentioned in
Return Value
The adjusted image.
Discussion
This method applies the Lanczos scale transform filter to an image. The effect creates the output image by scaling the input image based on the scale and aspect ratio properties provided.
The Lanczos scale filter uses the following properties:
inputImageAn image with the type CIImage.
scaleA
floatrepresenting the scaling factor used on the image as an NSNumber. Values less than1.0scale down the images. Values greater than1.0scale up the image.aspectRatioA
floatrepresenting the additional horizontal scaling factor used on the image as an NSNumber.
The following code creates a filter that results in a smaller scaled image with high quality:
func lanczosScale(inputImage: CIImage) -> CIImage {
let lanczosScaleFilter = CIFilter.lanczosScaleTransform()
lanczosScaleFilter.inputImage = inputImage
lanczosScaleFilter.scale = 0.3
lanczosScaleFilter.aspectRatio = 1
return lanczosScaleFilter.outputImage!
}[Image]