Ad

Python Display Image - AttributeError

Hi I just got a Raspberry Pi, and I'm working on some very simple code here. What I'm trying to do is to capture an image and display it.

import PIL
import Image
import picamera
camera = picamera.PiCamera()
camera.capture("image.jpg")
im = Image.open("image.jpg")
im.show()

There was no error, but the image would not show up.

I checked the file, the picture was taken, so no problem on that part of the code.

Would really like some help, thanks!

Ad

Answer

Python is case-sensitive. You are importing Image so use it.

Change image to Image in im = image("image.jpg") It'll become:

from PIL import Image
import picamera
camera = picamera.PiCamera()
camera.capture("image.jpg")
im = Image.open("image.jpg")
im.show()
Ad
source: stackoverflow.com
Ad