PIL images in CGI scripts

Uwe Becher ubecher at gmx.net
Fri Jun 21 14:05:37 EDT 2002


Well, i should have searched 2 days and 2 hours instead of two days.
I found a solution for my problem with

if sys.platform == "win32":
     import os, msvcrt
     msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)

I didn't know msvcrt yet.

Uwe

Uwe Becher wrote:
> 
> Hi together,
> 
> i try to generate dynamic images in Python CGI scripts on an apache
> server
> on windows. In my first attempts the browser showed miscoloured images.
> Searching the internet i learned, that i have to output the image as
> binary stream to stdout. I succeeded by calling the Python interpreter
> with the option -u via the shebang #!d:/python21/python.exe -u.
> My question:
> Is it possible to define the binary mode in the script without
> using the -u option?
> 
> Thankys in advance
> 
> Uwe



More information about the Python-list mailing list