[Image-SIG] StringIO seems to garble images in cgi
Sat, 7 Dec 2002 19:19:56 +0100
> The following almost works, unfortunately the image comes out garbled. I
> have tried a variety of images in case they are somehow corrupt- no dice. Am
> I missing a step?
try saving an image to disk from the browser, and also from within
the CGI, and compare the files. if the sizes differ, chances are that
your server is ignoring the "-u" option on the first line.
> #!c:/python22/python.exe -u
> import cgi, StringIO
> #import cgitb; cgitb.enable()
> import sys
> import Image
> image_tub = StringIO.StringIO()
> print 'Content-Type: image/jpeg\n'
> except Exception, errorMsg:
> print "Content-Type: text/html\n\n"
> print "Error Printing Image and Header to sys.stdout\n<p>\n%s<p>\n%s"
> %(Exception, errorMsg)