Writing an image

Werner Schiendl ws-news at gmx.at
Fri Nov 7 10:20:09 EST 2003


Hi,

Mr. Costington wrote:
> 
> 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?

The sys.stdout is obviously open in text (not binary) mode.

When you write "\n" (linefeed) you'll get "\r\n" (carriage return + 
linefeed) in the destination.

hth

Werner





More information about the Python-list mailing list