Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Display image from URL
#2
(Aug-25-2018, 09:13 PM)mr_byte31 Wrote: do I have to download it first before I display ?
Could to that,but can also get image as bytes and give data to image.open() using BytesIO.
import tkinter as tk
from PIL import ImageTk, Image
import os
import requests
from io import BytesIO

root = tk.Tk()
img_url = "https://www.marketbeat.com/scripts/temp/estimateswide4879.png"
response = requests.get(img_url)
img_data = response.content
img = ImageTk.PhotoImage(Image.open(BytesIO(img_data)))
panel = tk.Label(root, image=img)
panel.pack(side="bottom", fill="both", expand="yes")
root.mainloop()
Some PEP-8 fixes and * is gone.
Reply


Messages In This Thread
Display image from URL - by mr_byte31 - Aug-25-2018, 09:13 PM
RE: Display image from URL - by snippsat - Aug-25-2018, 09:59 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to display <IPython.core.display.HTML object>? pythopen 3 46,015 May-06-2023, 08:14 AM
Last Post: pramod08728
  Display transparent image as overlay jds8086 0 1,259 Apr-17-2022, 11:43 AM
Last Post: jds8086
Information Unable to display joystick's value from Python onto display box MelfoyGray 2 2,253 Nov-11-2020, 02:23 AM
Last Post: MelfoyGray
  Display the bottom image of the line and cut the upper image using Opencv jenkins43 1 3,261 May-27-2019, 06:56 AM
Last Post: heiner55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020