Check out example codes for "cifilter image preserve orientation". It will help you in understanding the concepts better.

Code Example 1

var filterNames: [String] = ["CIPhotoEffectTonal","CIPhotoEffectNoir","CIMaximumComponent","CIMinimumComponent","CIDotScreen", "CISepiaTone", "CIFalseColor", "CIColorInvert", "CIColorPosterize", "CIPhotoEffectChrome", "CIPhotoEffectInstant"]

    let CIfilterName = filterNames[indexPath.row]
    print(CIfilterName)

    let ciContext = CIContext(options: nil)
    let startImage = CIImage(image: originalImage)

    let filter = CIFilter(name: CIfilterName)
    filter!.setDefaults()

    filter!.setValue(startImage, forKey: kCIInputImageKey)
    let filteredImageData = filter!.valueForKey(kCIOutputImageKey) as! CIImage
    let filteredImageRef = ciContext.createCGImage(filteredImageData, fromRect: filteredImageData.extent)

    let originalOrientation: UIImageOrientation = (imageView.image?.imageOrientation)!
    let originalScale: CGFloat = (imageView.image?.scale)!
    let newPtImage: UIImage = UIImage.imageWithCGImage(filteredImageRef, scale: originalScale, orientation: originalOrientation)
    imageView.image = newPtImage

    imageView.image = UIImage(CGImage: filteredImageRef);

Learn ReactJs, React Native from akashmittal.com