ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> image-sig
image-sig
[Image-SIG] Re: PIL, popen, and GTK
by Fredrik Lundh other posts by this author
Jun 24 2004 10:21PM messages near this date
[Image-SIG] PIL, popen, and GTK | [Image-SIG] Patch to add .w and .h to Image objects.
Phillip Neumann wrote:
>  Im trying to develop my program with PIL.
>  Im popen a command, qcamshot, that gives me an ppm image from the
>  webcam. The ides is to process it with PIL, and show it with Py-GTK.
>  1) how do i get a pil image from memory? i.e. from
>  ppm = popen(' qcamshot','r').read()

popen() returns a file handle, so the following might work:

    ppm = Image.open(popen(...))

if not, wrap the image in a StringIO object:

    import StringIO
    data = popen(...).read()
    ppm = Image.open(StringIO.StringIO(data))

also see the fromstring() and frombuffer() functions in the Image
module docs.

</F> 




_______________________________________________
Image-SIG maillist  -  Image-SIG@[...].org
http://mail.python.org/mailman/listinfo/image-sig
Thread:
Phillip Neumann
Fredrik Lundh

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved