CGI to make PNG image
Take Sato
tkssato at yahoo.co.jp
Thu Aug 17 06:16:27 EDT 2000
I made a simple CGI script to return images on WinNT with Apache1.3.12.
It works all right to return JPEG,GIF,BMP images,
but not with PNG.
(IE5.0 and NS4.5 cannot understand it as correct image)
I don't know what's wrong with it.
Can anyone help me ?
-----------------------------
import Image
try:
import msvcrt,os #set standard output to binary mode
msvcrt.setmode(sys.stdout.fileno(),os.O_BINARY)
except: pass
im=Image.open("foo1.jpg")
... # some operation
print "Content-type: image/png"
print
im.save(sys.stdout,"png")
#NOTE! above script works fine if it's like following,
# (once saved as file and reopened.)
print "Content-type: image/png"
print
im.save("foo2.png","png")
print open("foo2.png","rb").read()
More information about the Python-list
mailing list