I\'m trying to set up a python script in cgi-bin that simply returns a header with content-type: image/png and returns the image. I\'ve tried opening the image and returnin
"rb" (in windows based environments it's usually the case.write it to sys.stdout.print "Content-type: image/png\n\n" actually prints 3 newlines (as print automatically adds one "\n" in the end. This may break your PNG file.Try:
sys.stdout.write( "Content-type: image/png\r\n\r\n" + file(filename,"rb").read() )