<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:"Courier New";}
span.pystring1
        {mso-style-name:py_string1;
        color:green;}
span.pykeyword1
        {mso-style-name:py_keyword1;
        color:#0000C0;
        font-weight:bold;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>I do not seem to have success in generating a dynamic image into Internet Explorer through CGI.  If I save the file and then load it, it works but when I try to keep the generated image dynamic…  I am using Python 2.6.5 and the corresponding PIL library.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal style='background:#F3F3F3'><span style='font-size:10.0pt;font-family:"Courier New"'>f = cStringIO.StringIO()<o:p></o:p></span></p><p class=MsoNormal style='background:#F3F3F3'><span style='font-size:10.0pt;font-family:"Courier New"'>img.save(f, <span style='color:green'>"PNG"</span>)<o:p></o:p></span></p><p class=MsoNormal style='background:#F3F3F3'><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='background:#F3F3F3'><b><span style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>print</span></b><span style='font-size:10.0pt;font-family:"Courier New"'> <span style='color:green'>"Content-type: image/png\n"</span><o:p></o:p></span></p><p class=MsoNormal style='background:#F3F3F3'><span style='font-size:10.0pt;font-family:"Courier New"'>f.seek(0)<o:p></o:p></span></p><p class=MsoNormal style='background:#F3F3F3'><b><span style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>print</span></b><span style='font-size:10.0pt;font-family:"Courier New"'> f.read()<o:p></o:p></span></p><p class=MsoNormal style='background:#F3F3F3'><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal>The above will just generate a screen filled with ascii characters and symbols.  I have also tried JPEG to no avail.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Below generates a blank image:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>sys.stdout.write('Status: 200 OK\r\n')<o:p></o:p></p><p class=MsoNormal>sys.stdout.write('Content-type: image/png\r\n\n')<o:p></o:p></p><p class=MsoNormal>sys.stdout.write('%s' % f.getvalue())<o:p></o:p></p><p class=MsoNormal>sys.stdout.write('\r\n')<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Can someone point out my error here?  Writing to file in a cgi environment is not a great thing to be doing.  Img.sav(‘test.png’) is valid.<o:p></o:p></p></div></body></html>