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?

Recommended Answers

All 3 Replies

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)

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.

thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.