Return to Snippet

Revision: 57135
at May 17, 2012 22:18 by satie83


Initial Code
// Resize the image
CIImage *ciImage = [CIImage imageWithContentsOfURL:<#ImageURL#>];
CIFilter *scaleFilter = [CIFilter filterWithName:@"CILanczosScaleTransform"];
[scaleFilter setValue:ciImage forKey:@"inputImage"];
[scaleFilter setValue:[NSNumber numberWithFloat:<#ratio#>] forKey:@"inputScale"];
[scaleFilter setValue:[NSNumber numberWithFloat:1.0] forKey:@"inputAspectRatio"];
CIImage *finalImage = [scaleFilter valueForKey:@"outputImage"];

Initial URL
http://goo.gl/dBxSF

Initial Description
Core Image provides a lot of filter to apply to images. Here there is a snippet to modify the size of the image using the Lanczos algorithm. You have to give the image URL and the ratio of the scale. If the ratio is smaller than 1 it reduce, otherwise it enlarges the image.

Initial Title
Image resize with CI

Initial Tags

                                

Initial Language
Objective C