Implement `show` function for PIL
@@ -167,6 +167,27 @@ def signal(signal, handler):
return None
_signal.signal = signal
+# MARK: - PIL Show
+
+import PIL.ImageShow
+
+def show_image(image, title=None, **options):
+ import os
+ import tempfile
+ import sharing
+
+ imgPath = tempfile.gettempdir()+"/image.png"
+
+ i = 1
+ while os.path.isfile(imgPath):
+ i += 1
+ imgPath = os.path.join(tempfile.gettempdir(), 'image '+str(i)+'.png')
+
+ image.save(imgPath,"PNG")
+ sharing.quick_look(imgPath)
+
+PIL.ImageShow.show = show_image
+
# MARK: - Run script
pyto.Python.shared.isSetup = True
