     
 }
 
+extension CGImage {
+    
+    func scaling(to size: CGSize) -> CGImage? {
+        guard let colorSpace = self.colorSpace else {
+            return nil
+        }
+        
+        let context = CGContext(data: nil,
+                                width: Int(size.width),
+                                height: Int(size.height),
+                                bitsPerComponent: bitsPerComponent,
+                                bytesPerRow: bytesPerRow,
+                                space: colorSpace,
+                                bitmapInfo: bitmapInfo.rawValue)
+        context?.draw(self, in: CGRect(origin: .zero, size: size))
+        
+        return context?.makeImage()
+    }
+    
+}
+

    public var secondaryColor: CGColor?
    public var detailColor: CGColor?
    
    public init(image: CGImage) {
        self.image = image
    }
    
    public func analyze() {

            } else {
                return nil
            }
        }  as [CACountedRGBColor]
        
        let edgeColors = edgeColorSet.objectEnumerator().allObjects.flatMap() { color -> CACountedRGBColor? in
            guard let rgbColor = color as? CARGBColor else {
