Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show PIL images on the screen?

I am doing some image editing with the PIL libary. The point is, that I don't want to save the image each time on my HDD to view it in Explorer. Is there a small module that simply enables me to set up a window and display the image?

like image 675
Bartlomiej Lewandowski Avatar asked Sep 24 '12 18:09

Bartlomiej Lewandowski


People also ask

How do I display PIL images?

Try setting the image format attribute explicitly to . png (i.e. im. format = "PNG" ) before the im. show() call.

Can I display image in full screen mode with PIL?

PIL has no native way of opening an image in full screen. And it makes sense that it can't. What PIL does is it simply opens your file in the default . bmp file viewing program (commonly, Windows Photos on Windows [although this is Windows version dependent]).


2 Answers

From near the beginning of the PIL Tutorial:

Once you have an instance of the Image class, you can use the methods defined by this class to process and manipulate the image. For example, let's display the image we just loaded:

     >>> im.show()

Update:

Nowadays theImage.show() method is formally documented in the Pillow fork of PIL along with an explanation of how it's implemented on different OSs.

like image 85
martineau Avatar answered Sep 17 '22 04:09

martineau


I tested this and it works fine for me:

from PIL import Image im = Image.open('image.jpg') im.show() 
like image 23
Hrvoje Avatar answered Sep 21 '22 04:09

Hrvoje