Using os.popen3() to get binary data
Christoph Krammer
redtiger84 at googlemail.com
Fri Apr 6 07:02:52 EDT 2007
Hello everybody,
I need to get the different frames from a GIF image in my python
script and want to use the giftopnm program from netpbm to get the
frames and directly convert them to pnm files. I tried to use the
following code:
for image in images:
if (image[0:3] == 'GIF'):
(si, so, se) = os.popen3('giftopnm -image=all', 'b')
si.write(image)
frame = so.readlines()
But with this code the script just hangs. When I interrupt the script,
I get the following error message:
Traceback (most recent call last):
File "/home/tiger/stock-spam/scripts/all_in_one.py", line 46, in ?
frames = so.readlines()
KeyboardInterrupt
close failed: [Errno 32] Broken pipe
Can somebody tell me, which command I have to use that the pipe will
be closed when the giftopnm returns? This program just prints the
converted images to stdout and terminates.
Thanks in advance,
Christoph
More information about the Python-list
mailing list