1

The following code does not display the image lists.jpg (in current dir):
print(dir(Image)) displays components; im.size, im.filename, im.format all return correct values.

What have I not done to display this jpg file?

from PIL import Image
im = Image.open("lists.jpg")
im.show()  # did not work -  perhaps due to the environment Jupyter Notebooks

Solution: replaced module with another with immediate results.

from IPython.display import Image
Image(filename='lists.jpg')
1
  • Why do you think it should be displayed? This code does nothing like that. The last line lists attributes of class Image. Commented Mar 28, 2017 at 21:20

2 Answers 2

1

I know it is quite late to post but I will do it for new readers.

This problem arises in case of Jupyter Notebooks. Using show() does not display the image. So discard calling show() like in the code below. This will display the image in the output of the cell.

from PIL import Image
im = Image.open("lists.jpg")
im
Sign up to request clarification or add additional context in comments.

Comments

0

To display the image on screen:

from PIL import Image
im = Image.open("lists.jpg")
im.show()

See also http://pillow.readthedocs.io/en/4.0.x/reference/Image.html

2 Comments

Hugo, I tired that and it did not work. I am using Jupyter Notebooks as my environment could that be tyhe reason for the difficulty?
@AFBanks how did "it not work"? There are known problems if you're using Windows.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.