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
Avspeechsynthesizer in Background Mode
"Apprequests" Dialog Reports Success, Recipients Receive Nothing
Highlight Just the Text in a Uilabel
How to Add an Identifier to Auto Layout Constraints in Interface Builder
Uiimagepicker Cameraoverlayview Appears on Retake Screen
How to Draw a Point Using Core Graphics
How to Set Http Header Fields in Objective-C
Passing Variables Between View Controllers
How to Properly Group a List Fetched from Coredata by Date
Nsoperationqueue Serial Fifo Queue
Corebluetooth: What Is the Lifetime of Unique Uuids
Ckquery from Private Zone Returns Only First 100 Ckrecords from in Cloudkit
Apple Llvm 6.0 Error: Clang Failed with Exit Code -1
iPhone Storage in Tmp Directory