Movatterモバイル変換
[0]ホーム
Newbie has question that's not exactly Python...
Andrew Dalkedalke at acm.org
Tue Apr 3 17:57:45 EDT 2001
Gary Walker:>Here's some actual code of mine that doesn't work:>>************************************>#!/usr/bin/python>>import StringIO, cgi, os, sys, string, Image>>im = Image.open('backgroundimage.gif') add--> , "rb" <-- here ^^to make itim = Image.open('backgroundimage.gif', "rb")else it won't work on MS Windows or Macs.># here I'll be drawing all over my image...>># Now I want to send it to a browser...>sfp = StringIO.StringIO()>im.save(sfp,'gif')>>print 'Content-Type: image/gif\r\n\r\n'Replace this withsys.stdout.write("Content-Type: image/gif\r\n\r\n")because print adds its own "\n" after it printsthe text.>sys.stdout.write(sfp.getvalue()) Andrewdalke at acm.org
More information about the Python-listmailing list
[8]ページ先頭