Move Pillow `show` implementation
@@ -122,6 +122,24 @@ for importer in (NumpyImporter, MatplotlibImporter, PandasImporter, PillowImport
def importModules():
try:
import matplotlib, numpy, pandas, PIL
+ 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
except:
pass
@@ -167,27 +185,6 @@ 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
