     }
 }
 
+//extension Data: KingFisherCompatible {
+//    public typealias CompatibleType = DataProxy
+//    public var kf: DataProxy {
+//        return DataProxy(proxy: self)
+//    }
+//}
 extension Data: KingFisherCompatible {
     public typealias CompatibleType = DataProxy
     public var kf: DataProxy {
         return DataProxy(proxy: self)
     }
 }
+
+//extension DataProxy {
+//    var imageFormat: ImageFormat {
+//        var buffer = [UInt8](repeating: 0, count: 8)
+//        (base as NSData).getBytes(&buffer, length: 8)
+//        if buffer == ImageHeaderData.PNG {
+//            return .PNG
+//        } else if buffer[0] == ImageHeaderData.JPEG_SOI[0] &&
+//            buffer[1] == ImageHeaderData.JPEG_SOI[1] &&
+//            buffer[2] == ImageHeaderData.JPEG_IF[0]
+//        {
+//            return .JPEG
+//        } else if buffer[0] == ImageHeaderData.GIF[0] &&
+//            buffer[1] == ImageHeaderData.GIF[1] &&
+//            buffer[2] == ImageHeaderData.GIF[2]
+//        {
+//            return .GIF
+//        }
+//        
+//        return .unknown
+//    }
+//}
 
 extension DataProxy {
     var imageFormat: ImageFormat {

    }
}


extension KingFisher where Base: Image {
    
    func draw(cgImage: CGImage?, to size: CGSize, draw: ()->()) -> Image {
        #if os(macOS)
            guard let rep = NSBitmapImageRep(
                bitmapDataPlanes: nil,
                pixelsWide: Int(size.width),
                pixelsHigh: Int(size.height),
                bitsPerSample: cgImage?.bitsPerComponent ?? 8,
                samplesPerPixel: 4,
                hasAlpha: true,
                isPlanar: false,
                colorSpaceName: NSCalibratedRGBColorSpace,
                bytesPerRow: 0,
                bitsPerPixel: 0) else
            {
                assertionFailure("[Kingfisher] Image representation cannot be created.")
                return base
            }
            rep.size = size
            
            NSGraphicsContext.saveGraphicsState()
            
            let context = NSGraphicsContext(bitmapImageRep: rep)
            NSGraphicsContext.setCurrent(context)
            draw()
            NSGraphicsContext.restoreGraphicsState()
            
            let outputImage = Image(size: size)
            outputImage.addRepresentation(rep)
            return outputImage
        #else
            
            UIGraphicsBeginImageContextWithOptions(size, false, scale)
            defer { UIGraphicsEndImageContext() }
            draw()
            return UIGraphicsGetImageFromCurrentImageContext() ?? base
            
        #endif
    }
    
    #if os(macOS)
    func fixedForRetinaPixel(cgImage: CGImage, to size: CGSize) -> Image {
    
    let image = Image(cgImage: cgImage, size: base.size)
    let rect = CGRect(origin: CGPoint(x: 0, y: 0), size: size)
    
    return draw(cgImage: cgImage, to: self.size) {
    image.draw(in: rect, from: NSRect.zero, operation: .copy, fraction: 1.0)
    }
    }
    #endif
}


extension CGContext {
    static func createARGBContext(from imageRef: CGImage) -> CGContext? {

        return .unknown
    }
}









