0

Hi, I'm a beginner, and just want to display an image using Python. I have this code...

from PIL import Image
Image.open("pic.jpg").show()

which according to what I've read, should work. However, it just opens Windows Photo Gallery and says 'There are no photos or videos selected'.

I have ensured that the image file is named correctly and is within the same directory as the Python script.

Any help?

2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by alicem
0

Never mind, seems it was something to do with Vista... solved it by doing this instead...

import Image, os

img = Image.open("image.jpg")
os.startfile(img.filename)
0

Im pretty sure that using the Image module is unnessicary for that. I think you can just use os and go:

import os
os.startfile("image.jpg")

Yep, just checked, it works perfectly on my computer.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.