Skip to content

Instantly share code, notes, and snippets.

@paskowski
Created January 1, 2018 18:44
Show Gist options
  • Save paskowski/a922c01d36ff6c543f46dd882cf49367 to your computer and use it in GitHub Desktop.
Save paskowski/a922c01d36ff6c543f46dd882cf49367 to your computer and use it in GitHub Desktop.
import UIKit
class BlurImageOperation: Operation {
var outputImage: UIImage?
override func main() {
guard let imageProvider = dependencies.first as? ImageProvider,
let providedImage = imageProvider.providedImage else { return }
let ciImage = CIImage(image: providedImage)!
guard let crystallize = CIFilter(name: "CICrystallize",
withInputParameters: [kCIInputRadiusKey: 30,
kCIInputImageKey: ciImage])
else { return }
let ciContext = CIContext()
guard let crystallizedImage = crystallize.outputImage else { return }
let cgImage = ciContext.createCGImage(crystallizedImage,
from: crystallizedImage.extent)
outputImage = UIImage(cgImage: cgImage!)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment