         let rect = CGRect(origin: .zero, size: scaledSize)
         UIGraphicsBeginImageContextWithOptions(rect.size, false, scale)
         defer { UIGraphicsEndImageContext() }
-        guard let cgImage = self.cgImage, let context = UIGraphicsGetCurrentContext() else { return nil }
+        guard let cgImage = self._makeCgImage(), let context = UIGraphicsGetCurrentContext() else { return nil }
         context.clip(to: rect)
         if horizontally {
             context.rotate(by: CGFloat.pi)

        
        let bitmapInfo = CGBitmapInfo(rawValue: (0x0 << 0xc)|CGImageAlphaInfo.premultipliedLast.rawValue)
        guard let thumbnailed  = thumbnail(scalesToFit: length) else { return [] }
        guard let thumbnailedCgImage = thumbnailed.cgImage else { return [] }
        let colorSpace = CGColorSpaceCreateDeviceRGB()
        
        guard let context = CGContext(data: nil, width: thumbnailedCgImage.width, height: thumbnailedCgImage.height, bitsPerComponent: 8, bytesPerRow: thumbnailedCgImage.width*4, space: colorSpace, bitmapInfo: bitmapInfo.rawValue) else { return [] }

        // Check pre-conditions.
        guard size.width >= 1.0 && size.height >= 1.0 else { return nil }
        guard let input = cgImage else { return nil }
        if let _ = mask { guard let _ = mask?._makeCgImage() else { return nil } }
        
        let hasBlur = radius > .ulpOfOne
        let hasSaturationChange = fabs(saturationDeltaFactor - 1.0) > .ulpOfOne
