new images from strings using PIL

Max M maxm at mxm.dk
Sun Mar 3 15:52:38 EST 2002


BL wrote:

> pixels = "1 2 3 4 5 6" //test pixels
> im = Image.fromstring("I", (2,1), pixels) //create a 3x2 image from pixels
> These values are obviously wrong.  Why isn't my 3x2 image being created with
> the proper pixel intensities?

I think that the function is just meant as a way to generate an image 
via a string, in lack of a better data format.

So the string is not a string of pixel values (pun inteded) but image 
data stored in a string indstead of a file.

Your string would probably look a little like this:

"GIF89aEURÿÿÿ!ù¤&(¤&(g(/&dg;"

Well actually it wouldn't. But the general idea is that the string would 
be how an image file like a gif would look like if opened in a text editor.

regards Max M




More information about the Python-list mailing list