[Image-SIG] PIL.Image and binary data in SQL
Fredrik Lundh
fredrik@pythonware.com
Tue, 16 Oct 2001 09:47:34 +0200
klint price wrote:
> Does anyone know how use the PIL.Image to read binary image
> data from a database, create thumbnails, and out put the thumbnails
> to the browser using a binarywrite, or something to that effect?
> Using IIS5, MSSQL 7, and ASP.
lots of people have written web gallery tools based on PIL; a
google search should help you find plenty of sample code.
the PIL parts could look something like this:
import StringIO
data = read_from_database()
file = StringIO.StringIO(data)
image = Image.open(file)
image.thumbnail((128, 128))
outfile = StringIO.StringIO()
image.save(outfile, "JPEG")
data = outfile.getvalue()
write_to_web_client(data)
</F>