简体   繁体   中英

How to successfully show an image with Pillow in Python?

I used the Pillow library to show an image (called 'beach_sky.jpg'), but when I use the show() function, nothing happens! I read that a utility called 'xv' is necessary... I'm using an Android device by the way. Here's the code :

from PIL import Image

img = Image.open('beach_sky.jpg')
img.show()

Terminal output:

"""
WARNING: linker: _imaging.cpython-36m.so: unused DT entry: type 0x6ffffffe arg 0x45ec
WARNING: linker: _imaging.cpython-36m.so: unused DT entry: type 0x6fffffff arg 0x1

[Program finished]
"""

Can you help me somehow showing the image?

You can do like this

from tkinter import *
from PIL import ImageTk, Image

root = Tk()
image = Image.open("<b>image path</b>")
render = ImageTk.PhotoImage(image)
label = Label(root, image=render)
label.image = render

label.pack()

root.mainloop()
#Simple Enough

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM