PyCairo, PIL and StringIO

Discussion in 'Python' started by Jair Trejo, Jan 2, 2008.

  1. Jair Trejo

    Jair Trejo Guest

    I'm doing some image processing in PIL, and I want to
    display the results in a GTK window using PyCairo, so
    I create a Cairo image surface from the PIL Image like
    this:

    mfile = StringIO.StringIO()
    final.save(mfile, format="PNG")
    ima =
    cairo.ImageSurface.create_from_png(mfile)
    mfile.close()
    return ima

    Where final is a PIL image. The problem is, I get a
    IOError: error while reading from Input Stream.

    ¿Any idea of why is this happening? I tried saving to
    a temporary file, i.e., replace the above code with:

    final.save('final.png')
    ima =
    cairo.ImageSurface.create_from_png('final.png')

    Instead of a StringIO object, and it works just fine.


    ____________________________________________________________________________________
    ¡Capacidad ilimitada de almacenamiento en tu correo!
    No te preocupes más por el espacio de tu cuenta con Correo Yahoo!:
    http://correo.yahoo.com.mx/
     
    Jair Trejo, Jan 2, 2008
    #1
    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. Jair Trejo

    Re: Re: PyCairo, PIL and StringIO

    Jair Trejo, Jan 2, 2008, in forum: Python
    Replies:
    0
    Views:
    488
    Jair Trejo
    Jan 2, 2008
  2. Skip Montanaro
    Replies:
    0
    Views:
    167
    Skip Montanaro
    May 30, 2013
  3. Cameron Simpson
    Replies:
    0
    Views:
    112
    Cameron Simpson
    May 31, 2013
  4. Göktuğ Kayaalp
    Replies:
    0
    Views:
    127
    Göktuğ Kayaalp
    May 31, 2013
  5. Skip Montanaro
    Replies:
    0
    Views:
    123
    Skip Montanaro
    May 31, 2013
Loading...

Share This Page