[PYTHON IMAGE-SIG] The PIL library -- specification for release 0.1
Thu, 21 Mar 1996 09:06:19 +0100
> Interesting. Will this interact with Tk? I'd love to be able to
> stuff images in a Tk "photo image" object without having to write it
> to a file in GIF or PPM format first...
Of course. I had Grail in mind when I designed some of the PIL
features (more on this below). I mean, imagine what you can do if you
stuff image processing support into a web-browser!
Anyway, I have a Tk photo image interface that seems to be working,
but I haven't had the time to figure out how add it to Tk in a clean
way (the current version is boldly patched into Tk. Are there any Tk
experts out there that have done similar things, drop me a line!).
Anyway, this interface allows you to create a photo image out of a PIL
Even more interesting for Grail, PIL allows you to decode data
incrementally (including TIFF). Each raster data decoders has an
"expose" method that takes a string of bytes, and returning the amount
of data it was able to use.
If we boldly ignore the code required to identify and read the file
header (some clever use of StringIO is required here), and bind the
decoder to the image memory, you can do something like:
buf = sio.getvalue()[headersize:]
s, e = decoder.expose(buf)
if s < 0:
break # e is error code, 0 if completed
buf = buf[s:]
s = io.read(bufsize)
if not s:
break # file is truncated
buf = buf + s
Just add some code to set the bufsize based on the connection speed,
and to determine when its appropriate to update the screen, and you
have a nice, progressive image display...
Maybe in Grail 0.4?
IMAGE-SIG - SIG on Image Processing with Python
send messages to: email@example.com
administrivia to: firstname.lastname@example.org