salajadin
salajadin

Reputation: 11

PIL attribute error

I tried to do a scrip with Pillow but i have a instance method error the code is something like that

import StringIO
import subprocess
from PIL import Image
command = "fswebcam -q --no-info --no-banner --jpeg -d /dev/video0 -i 0 -r 100x75 -"
imageData = StringIO.StringIO()
imageData.write(subprocess.check_output(command, shell=True))
imageData.seek(0)
im = Image.open(imageData)
print buffer1[1,1]

and when i tried to execute them i get

File "prueba.py", line 17, in main
    print im[1,1]
  File "/usr/lib/python2.7/dist-packages/PIL/Image.py", line 528, in __getattr__
    raise AttributeError(name)
AttributeError: __getitem__

so what is wrong? thanks in advance

Upvotes: 0

Views: 5207

Answers (1)

Mark Ransom
Mark Ransom

Reputation: 308101

You can't subscript the image object directly, you must use the load method to create an access object.

im = Image.open(imageData)
buffer1 = im.load()
print buffer1[1,1]

Upvotes: 2

Related Questions