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


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


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