Skip to content

Instantly share code, notes, and snippets.

@dsowsy
Created October 28, 2015 17:35
Show Gist options
  • Save dsowsy/cefba186d3582cb2af4e to your computer and use it in GitHub Desktop.
Save dsowsy/cefba186d3582cb2af4e to your computer and use it in GitHub Desktop.
The pattern I use for chaining GPUImage filters on a single UIImage
import Foundation
extension UIImage {
func blur() -> UIImage {
let boxBlur = GPUImageBoxBlurFilter()
boxBlur.blurRadiusInPixels = 4.0
return boxBlur.imageByFilteringImage(self)
}
func canny() -> UIImage {
let canny = GPUImageCannyEdgeDetectionFilter()
return canny.imageByFilteringImage(self)
}
}
// Example usage:
// let result = image.blur().canny()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment