         return self.cgImage.map { SVGContext.ImageTableKey($0) }
     }
     
-    fileprivate func encode(using storageType: MediaType, properties: Any) -> String? {
-        return self.cgImage?.encode(using: storageType, properties: properties)
-    }
-}
-
-extension SVGContext {
-    
-    public func draw(image: CGImageRep, transform: SDTransform, using storageType: MediaType = .png, properties: [CGImageRep.PropertyKey : Any] = [:]) {
-        self._draw(image: image, transform: transform, using: storageType, properties: properties)
-    }
-    
-    public func draw(image: CGImage, transform: SDTransform, using storageType: MediaType = .png, properties: [CGImageRep.PropertyKey : Any] = [:]) {
-        self._draw(image: image, transform: transform, using: storageType, properties: properties)
+    fileprivate func encode(using storageType: MediaType, resolution: Resolution, properties: Any) -> String? {
+        return self.cgImage?.encode(using: storageType, resolution: resolution, properties: properties)
+    }
+}
+
+extension SVGContext {
+    
+    public func draw(image: CGImageRep, transform: SDTransform, using storageType: MediaType = .png, resolution: Resolution = .default, properties: [CGImageRep.PropertyKey : Any] = [:]) {
+        self._draw(image: image, transform: transform, using: storageType, resolution: resolution, properties: properties)
+    }
+    
+    public func draw(image: CGImage, transform: SDTransform, using storageType: MediaType = .png, resolution: Resolution = .default, properties: [CGImageRep.PropertyKey : Any] = [:]) {
+        self._draw(image: image, transform: transform, using: storageType, resolution: resolution, properties: properties)
     }
 }
 

                "height": "\(image.height)",
            ])
            
            guard let encoded = image.encode(using: storageType, properties: properties) else { return }
            _image.setAttribute(for: "href", namespace: "http://www.w3.org/1999/xlink", value: encoded)
            
            defs.append(_image)

        return SVGContext.ImageTableKey(self)
    }
    
    fileprivate func encode(using storageType: MediaType, resolution: Resolution, 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 }
