[Image-SIG] Question from a newbie

Mike Miller mmiller3@iupui.edu
17 Feb 2000 14:08:29 -0600


A couple of small corrections...  file.readlines returns a list
of lines, each of which would have to be split separately.  It is
simpler to do a file.read(), which returns one long string.

>>> import string, Image, array
>>> 
>>> file = open('test.txt', 'r')
>>> 
>>> text = string.split(file.read())
>>> 
>>> for i in range (len(text)): 
...    text[i] = string.atof(text[i])
>>> 
>>> imdata = array.array('B', data).tostring()
>>> 
>>> datasize = (41,41)
>>> im = Image.fromstring('L', datasize, imdata)
>>> 
>>> im.save('test.tiff', "TIFF")
>>> im.show()


Mike

-- 
Michael A. Miller                      mmiller3@iupui.edu
  Krannert Institute of Cardiology, IU School of Medicine