summaryrefslogtreecommitdiff
blob: 8c4bd2a6b9f9ed30a7ee3de5aecb35b5f5c6c94d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
--- Lib/misc/pilutil.py.orig	2007-06-06 14:28:07.000000000 +0100
+++ Lib/misc/pilutil.py	2007-06-06 14:44:10.000000000 +0100
@@ -2,6 +2,7 @@
 
 import types
 import numpy
+import tempfile
 
 from numpy import amin, amax, ravel, asarray, cast, arange, \
      ones, newaxis, transpose, mgrid, iscomplexobj, sum, zeros, uint8
@@ -226,17 +227,20 @@
     """Simple showing of an image through an external viewer.
     """
     im = toimage(arr)
-    if (len(arr.shape) == 3) and (arr.shape[2] == 4):
-        try:
-            import os
-            im.save('/tmp/scipy_imshow.png')
-            if os.system("(xv /tmp/scipy_imshow.png; rm -f /tmp/scipy_imshow.png)&"):
-                raise RuntimeError
-            return
-        except:
-            print "Warning: Alpha channel may not be handled correctly."
+    fnum,fname = tempfile.mkstemp('.png')
+    try:
+        im.save(fname)
+    except:
+        raise RuntimeError("Error saving temporary image data.")
+
+    import os
+    os.close(fnum)
+    cmd = os.environ.get('SCIPY_PIL_IMAGE_VIEWER','see')
+    status = os.system("%s %s" % (cmd,fname))
+    os.unlink(fname)
+    if status != 0:
+        raise RuntimeError('Could not execute image viewer.')
 
-    im.show()
     return
 
 def imresize(arr,size):