[Image-SIG] Help with PIL image.tostring
Fredrik Lundh
fredrik at pythonware.com
Fri May 18 11:09:40 CEST 2007
Robert wrote:
> I'm new to PIL and wanted to use Image.tostring for inline graphics
> under mod-python. Seems like a good fit but I can't seem to come up with
> the format of the required second parameter when you do
>
> output = im.tostring ("jpeg", ???)
tostring() should only be used if you want to transfer the actual pixels
to some other library (e.g. numpy), or if you're doing custom encoding
for non-standard formats.
if you want to save an image in a standard format, use im.save() and a
StringIO buffer instead:
f = StringIO.StringIO()
im.save(f, "JPEG")
data = f.getvalue()
</F>
More information about the Image-SIG
mailing list