[Image-SIG] Creating HUGE images...
Fri, 13 Aug 1999 19:10:30 +0200
Kevin Cazabon <KCAZA@cymbolic.com> wrote:
> I'm trying to develop an easy method to create images much larger than the memory
> available on the host computer, and have one big question:
> -Is there any way to create a NEW image on the hard drive (with blank background)
> without first creating it in memory? This way, I can create the 'canvas' as large as
> I want, and paste in small chunks of data manually as I go, staying within the memory
> limits of the machine. (Writing to an existing file shouldn't be a problem, just
> creating the blank file in the first place is causing me problems)
not in PIL 1.0, but if you're prepared to
hack around a little, it wouldn't be that
hard to tweak TiffImagePlugin to support
something like this. here's what I would
do, if I had the time:
1) add an optional argument to _save
to make it *return* the arguments to
ImageFile._save, rather than calling
2) create image snippets in a loop,
calling ImageFile._save for each piece.
the calling code would look something
file = "out.tif"
fp = open(file, "wb")
im = Image.new(mode, (1, 1), None)
im.size = width, height # ouch!
tile = TiffImagePlugin._save(im, fp, file, create=1)
format, bbox, offset, info = tile
for y in range(0, height, 256):
... create 256-pixels height snippet ...
ImageFile._save(im, fp, [format,
(0, y, width, y+256), offset, info)])
offset = offset + whatever
(completely untested, of course)