Cifilter Output Image Nil

CIFilter output image nil

You cannot call UIImage(CIImage:) and use that UIImage as the image of a UIImageView. UIImageView requires a UIImage backed by a bitmap (CGImage). A UIImage instantiated with CIImage has no bitmap; it has no actual image, it's just a set of instructions for applying a filter. That is why your UIImageView's image is nil.

Objective C: CIFilter returning nil image

I believe the correct name of the filter is CIPhotoEffectTransfer, not CIphotoeffectTransfer.

Try this code...I have used it for photo filtering in the past so I know it works:

+ (UIImage*)applyFilter:(UIImage*) photo {
UIImageOrientation orientation = photo.imageOrientation;
CIImage* image = [CIImage imageWithCGImage:photo.CGImage];
CIContext *context = [CIContext contextWithOptions:nil];
CIFilter *filter = [CIFilter filterWithName:@"CIPhotoEffectTransfer"];
[filter setValue:image forKey:kCIInputImageKey];
CIImage *outputImage = [filter outputImage];
CGImageRef cgimg = [context createCGImage:outputImage fromRect:[outputImage extent]];
UIImage *newPhoto = [UIImage imageWithCGImage:cgimg scale:1.0 orientation:orientation];
CGImageRelease(cgimg);
context = nil;
return newPhoto;

}

Core Image TileEffect filters in swift are returning nil image

Thanks, everyone. Replacing one line code solved my problem
From

let cgimg = context.createCGImage(filter!.outputImage!, from: filter!.outputImage!.extent)

To

 let cgimg = context.createCGImage(filter!.outputImage!, from: originalImage.extent)

Core image filter's output image is nil second time it is run on a UIImage

I had the same issue before. There is no problem in your code. I think what's wrong is the picture you use. This basic production process without CIContext cannot handle picture with alpha channel. I think you may be using a picture with alpha channel such as an icon or something. Change your picture with photo and have a try again.



Related Topics



Leave a reply



Submit