[PIL] about the difference between pudata and putpixel

Hillairet Julien jh at nospam.com
Sun Aug 29 06:54:41 EDT 2004


Hello,

I don't understand how "putdata" from the PIL works :

I've got a (N,N) matrix : "color" (an array from numarray lib.), where
(N,N) is the size of a image.

The next code, give to each pixel of the image the color (an integer
0~255) which is associate in the "color" matrix (an integer matrix,
0~255). It works well, but it's a bit slow:

for i in range(N):
    for j in range(N):
        im.putpixel((i,j), color[i][j])

Although, this code doesn't work:

im.putdata(color)

There is no error message, but the image's pixels stay black (0) ! (The
color matrix is not an 0-matrix !)


Is someone can explain me my misunderstanding of putdata ?


Thanks a lot,

Julien Hillairet



More information about the Python-list mailing list