new images from strings using PIL

BL metaliu at yahoo.com
Fri Mar 1 16:47:57 EST 2002


New at python and PIL so bear with me:

I'm having difficulties creating images from strings.  Basically, I have a
string of integers I would like to create an image from.  I'm trying to use
python's PIL function Image.fromstring() to do this (any other methods of
doing this would be appreciated).  So I do:

pixels = "1 2 3 4 5 6" //test pixels
im = Image.fromstring("I", (2,1), pixels) //create a 3x2 image from pixels

I'm not actually sure how to read the pixel data in im.  im.getdata()
returns:
<ImagingCore object at 00810B08>

Also, im.getextrema() returns:
(540155953, 540287027)

These values are obviously wrong.  Why isn't my 3x2 image being created with
the proper pixel intensities?

Thanks in advance,
Bill





More information about the Python-list mailing list