 
 extension AnyImage: SVGImageProtocol {
     
-    fileprivate var imageTableKey: SVGContext.ImageTableKey {
+    fileprivate var imageTableKey: SVGContext.ImageTableKey? {
         return SVGContext.ImageTableKey(self)
     }
     
-    fileprivate func encode(using storageType: MediaType, properties: [ImageRep.PropertyKey : Any]) -> String? {
+    fileprivate func encode(using storageType: MediaType, properties: Any) -> String? {
         guard let mediaType = storageType.media_type_string else { return nil }
+        guard let properties = properties as? [ImageRep.PropertyKey : Any] else { return nil }
         guard let data = self.representation(using: storageType, properties: properties) else { return nil }
         return "data:\(mediaType);base64," + data.base64EncodedString()
     }

        case image(AnyImage)
        case data(Data)
        
        init(_ image: AnyImage) {
            self = .image(image)
        }


extension SVGContext {
    
    private func _draw(image: SVGImageProtocol, transform: SDTransform, using storageType: MediaType, properties: Any) {
        
        guard !self.transform.determinant.almostZero() else { return }
        
        guard let key = image.imageTableKey else { return }
        
        let id: String
        
