[Image-SIG] Help on accessing pixels values

Fredrik Lundh fredrik at pythonware.com
Sat Jun 24 17:14:59 CEST 2006

bestdomdom wrote:

> First please forgive me for asking such a basic question but I am a newbie
> to Python, to programming and I am alone with my IT worries.
> I would like to access pixels values in order to make some computations but
> with the 1.1.6 PIL, I don't understand.
> As an example, here is what I do:
> import Image
> im = Image.open("myimage.jpg")
> pixel=im.load()
> print pixel [0,0] # to see the value of pixel[0,0]
> x=(0,0,0) #black in RGB
> pixel[0,0]=x # to set the first pixel in black
> This gives me an error : "TypeError: unsubscriptable object".
> I believe I am doing something wrong ;(

are you sure you have PIL 1.1.6 ?  what does

     >>> import Image
     >>> Image.VERSION

print ?


More information about the Image-SIG mailing list