Display of JPEG images from Python

Discussion in 'Python' started by David, Jan 6, 2006.

  1. David

    David Guest

    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
     
    David, Jan 6, 2006
    #1
    1. Advertising

  2. David

    Méta-MCI Guest

    Hi!

    Example:

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




    @-salutations

    Michel Claveau
     
    Méta-MCI, Jan 6, 2006
    #2
    1. Advertising

  3. David

    Guest

    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
     
    , Jan 6, 2006
    #3
  4. David

    David Guest

    Svien and Michel,

    Thanks for your help. Much appreciated.

    David Lees
     
    David, Jan 16, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Jones
    Replies:
    0
    Views:
    1,298
    Chris Jones
    Jun 25, 2003
  2. lovaspillando
    Replies:
    0
    Views:
    1,049
    lovaspillando
    Aug 26, 2007
  3. Ivan Alameda Carballo
    Replies:
    0
    Views:
    506
    Ivan Alameda Carballo
    Aug 26, 2007
  4. Robert
    Replies:
    2
    Views:
    166
    Florian Groß
    Sep 9, 2005
  5. Ron Brennan

    JPEG images sometimes don't display.

    Ron Brennan, Sep 30, 2004, in forum: Javascript
    Replies:
    5
    Views:
    156
    Ron Brennan
    Oct 2, 2004
Loading...

Share This Page