Display of JPEG images from Python

D

David

I would like to display a JPEG image from Python on a Windows machine.
I Googled 'python jpeg display' and have not found what I am looking
for, which is code I can call directly and pass the image. I see the
PIL library lets me do all sorts of image manipulation, but is there a
convenient way to display results? I guess I could issue shell commands
to a graphics display package such as IrfanView, but I thought there
might be a cleaner method.

david lees
 
M

Méta-MCI

Hi!

Example:

import Image
Image.open('Titi.jpg').show()




@-salutations

Michel Claveau
 
S

svbrk

You can f.i. use wxPython (www.wxPython.org). Here is a compact and
ugly, but (almost) minimal, example of a python script that shows an
image file:

import wx
a = wx.PySimpleApp()
wximg = wx.Image('img.jpg',wx.BITMAP_TYPE_JPEG)
wxbmp=wximg.ConvertToBitmap()
f = wx.Frame(None, -1, "Show JPEG demo")
f.SetSize( wxbmp.GetSize() )
wx.StaticBitmap(f,-1,wxbmp,(0,0))
f.Show(True)
def callback(evt,a=a,f=f):
# Closes the window upon any keypress
f.Close()
a.ExitMainLoop()
wx.EVT_CHAR(f,callback)
a.MainLoop()

-svein
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top