Skip to content

Commit 4585f6f

Browse files
KarthikRIyermarcrasi
authored and
marcrasi
committed
add function to display base64 png image (#63)
1 parent fd83254 commit 4585f6f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

EnableIPythonDisplay.swift

+7
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,10 @@ extension PythonObject {
8080
}
8181

8282
IPythonDisplay.enable()
83+
84+
func display(base64Png: String) {
85+
let displayImage = Python.import("IPython.display")
86+
let codecs = Python.import("codecs")
87+
let imageData = codecs.decode(Python.bytes(base64Png, encoding: "utf8"), encoding: "base64")
88+
displayImage.Image(data: imageData, format: "png").display()
89+
}

0 commit comments

Comments
 (0)