[Image-SIG] Help: how can I use img.tostring()

DrTebi DrTebi" <drtebi@yahoo.com
Wed, 16 Apr 2003 04:56:01 +0200


Hello,
Following are two examples, the first doesn't work, the second does.
The working example is fine, but my problem is that I want to actually use
the thumb data for a shell script (to be exact: I am using the XFS file
system on a Gentoo Unix system and am trying to write a python script that
will set a "thumbnail" attribute as binary data to the original image).

What am I understanding wrong with tostring() ?

First Example
-------------
# this doesn't work
import Image

img = Image.open('1882.jpg')
img.thumbnail((128,128))

thumb = img.tostring()

print """Content-type: image/jpeg\r\n"""
print thumb


Second Example
--------------
# this works
import Image
import sys

img = Image.open('1882.jpg')
img.thumbnail((128,128))

print """Content-type: image/jpeg\r\n"""
img.save(sys.stdout, "JPEG")


Thanks for any help,
DrTebi