Creating very large images using Python Image Library

python, python-imaging-library

Solution

You may try to use GDAL library. It provides bindings to Python. Here is combined tutorial presenting how to read and write images using C++, C and Python APIs Depending on GDAL operations and functions being used, GDAL can handle very large images and process images which are too large to be held in RAM.

Problem

I'm trying to create a very large image (25000x25000) by pasting together many smaller images. Upon calling Image.new() with such large dimensions, python runs out of memory and I get a MemoryError. Is there a way to write out an image like this incrementally, without having the whole thing resident in RAM? EDIT: Using ImageMagick's `montage` command, it seems possible to create arbitrarily sized images. It looks like it's not trying loading the final image into RAM (it uses very little memory during the process) but rather streaming it out to disk, which is ideal.

Original source