[Image-SIG] Workarounds for MemoryErrors
Laura & Edward Cannon
cannon.el at gmail.com
Mon Jun 22 19:36:59 CEST 2009
Off the top of my head I would divide the image into horizontal bands
and only work on one part at a time, writing the rest to disk. At the
final join I would write a custom file writter that wrote to some very
simple file format such as .tga or .bmp and could handle just
appending the new pixel data.
On Mon, Jun 22, 2009 at 9:52 AM, B. Bogart<ben at ekran.org> wrote:
> Hello all,
> I want to create a very large RGBA image (96000x72000 pixels).
> I have 4GB of RAM.
> Is there an easy way of getting around this error by having PIL only
> allocate one section of the image at a time?
> If PIL does not have any internal trick to work with large images then
> I'll have to make 4+ smaller images one at a time, but then I'm not sure
> how I could combine them without needing to allocate a memory chunk for
> the whole image.
> Otherwise I suppose I'll have to try with some other language, perhaps
> C/SDL, though a quick calculation seems to show that such a large RGBA
> image is just unworkable. Is there some way of using disk space rather
> than memory? Does not matter if it is slow, just that it is possible!
> Any advice?
> Image-SIG maillist - Image-SIG at python.org
More information about the Image-SIG