Writing an image

Mr. Costington noahd at juno.no.spam.com
Fri Nov 7 09:53:49 EST 2003


Hi all, I was trying to hava a CGI script return an image, but it was coming
back corrupted.  So I tried this simple non-CGI test and still get errors:

import sys
image = open('pic.jpg','rb').read()
sys.stdout.write(image)

When I run this like "python pic.py > pic2.jpg"
The resulting pic2.jpg is not identical to the original.  I looked at it in
a hex editor, and it seems to be identical with the original pic.jpg, except
for several 0D (carraige return) characters inserted throughout the file.

I tried this with Python 2.2.1 and 2.3.2.  What's going on?
Thanks in advance,
-Noah








More information about the Python-list mailing list