         var bitmapInfo: UInt32 = CGBitmapInfo.ByteOrder32Big.rawValue
         bitmapInfo |= CGImageAlphaInfo.PremultipliedLast.rawValue & CGBitmapInfo.AlphaInfoMask.rawValue
         let context = CGBitmapContextCreate(data.mutableBytes, Int(size.width), Int(size.height), 8, 4 * Int(size.width), CGColorSpaceCreateDeviceRGB(), bitmapInfo)!
-        CGContextDrawImage(context, CGRect(origin: .zero, size:size), trimmedImage.CGImage)
+        CGContextDrawImage(context, CGRect(origin: .zero, size:size), trimmedImage.CGImage!)
         let words = UnsafeMutablePointer<UInt32>(data.mutableBytes)
 
         let start = NSDate()

        bitmapInfo |= CGImageAlphaInfo.PremultipliedLast.rawValue & CGBitmapInfo.AlphaInfoMask.rawValue
        let context = CGBitmapContextCreate(pixelBuffer.contents(), Int(size.width), Int(size.height), 8, 4 * Int(size.width), CGColorSpaceCreateDeviceRGB(), bitmapInfo)!
        CGContextClearRect(context, CGRect(origin: .zero, size:size))
        CGContextDrawImage(context, CGRect(origin: .zero, size:size), trimmedImage.CGImage)
        
        let cmdHorizontal:MTLCommandBuffer = {
            let cmdBuffer = queue.commandBuffer()

    
    var image:UIImage! {
        didSet {
            precondition(image.CGImage != nil, "SNTrimController does not support an image created from CIImage.")
            guard let device = SNTrimController.device else {
                return
            }
