Home

Awesome

FaceCrop

CGImage extension that utilizes Apple's Vision Framework to detect and center faces.

Example

Usage

cgImage.faceCrop { [weak self] result in
    switch result {
    case .success(let cgImage):
        DispatchQueue.main.async { self?.imageView.image = UIImage(cgImage: cgImage) }
    case .notFound, .failure( _):
        print("error")
    }
}

If you need to crop a UIImage - you can always access its CGImage by calling .cgImage.

===

For more information consider visiting this in-depth artictle on Medium.

Huge thanks to Anastasios Grigoriou for his work on this project!