[Image-SIG] Can't show() images
joelh@neosoft.com
joelh@neosoft.com
Sun, 9 Jul 2000 18:17:54 -0500 (CDT)
I just installed Python1.5.2 and PIL1.1 and am having problems displaying images. The installs seem to have worked fine (other than a test error on popen2 which I patched). I'm running RedHat 6.1, kernel 2.2.12, GNU libc 2.1.2. In following the PIL Tutorial I obtain:
>>> import Image
>>> im = Image.open("test.ppm")
>>> print im.format, im.size, im.mode
PPM (128, 128) RGB
>>> im.show()
Traceback (innermost last):
File "<stdin>", line 1, in ?
File "/mydir/lib/python1.5/site-packages/PIL/Image.py", line 697, in show
_showxv(self, title, command)
File "/mydir/lib/python1.5/site-packages/PIL/Image.py", line 977, in _showxv
file = self._dump(format=format)
File "/mydir/lib/python1.5/site-packages/PIL/Image.py", line 314, in _dump
file = file + "." + format
TypeError: illegal argument type for built-in operation
It seems that 'format' is set to 'None' and python doesn't like to concatenate that to a string. (Run by itself, xv displays the test.ppm file fine.)
I then tried the Postscript Printing script in the Tutorial:
#####
import Image
import PSDraw
im = Image.open("test.ppm")
title = "lena"
box = (1*72, 2*72, 7*72, 10*72) # in points
ps = PSDraw.PSDraw()
ps.begin_document(title)
# draw the image
ps.image(box, im, 75)
ps.rectangle(box)
ps.end_document()
#####
It generated a large postscript file but when I try to view it in ghostscript I get the following error:
Error: /undefined in gsize
The postscript file contains the following (in addition to a lot more):
gsize
226.560000 370.560000 translate
0.960000 0.960000 scale
gsave
10 dict begin
/buf 384 string def
128 128 scale
128 128 8
[128 0 0 -128 0 128]
I'm obviously new to python and have no idea what's going on. Any help would be much appreciated.
Thanks
jh