unsigned char array -> buffer

Wayne Witzel III wwitzel3 at gmail.com
Tue Oct 19 17:49:36 CEST 2004

> My problem (no problem with asp and perl, same with php) is, that I would
> like to read the imagedata directly into a string of unsigned chars and
> then print it to the user agent (webbrowser) in binary mode.
# this example assumes you are using PIL
# this example assume mod_python, but can be easily modified.
def displayJpeg():
    im = Image.Open(file)
    imdata = StringIO()
    im.save(imdata, "JPEG")
    del im

    req.content_type = "Content-type: image/jpeg"
    return imdata.getValue()

Hope this helps in some way? I think I might have misunderstood the
question though.

More information about the Python-list mailing list