[Image-SIG] Re: Re: buffer is not large enough

Fredrik Lundh fredrik at pythonware.com
Thu Apr 15 12:39:38 EDT 2004


Manik Bali wrote:

> >>> import Image
> >>> im = Image.open("glc2000_beta3.pgm")
> >>> im.size
> (40320, 14673)

note that 40320*14673 is 591615360, which indicates that the file
you're trying to read is truncated.

did you try the workaround I suggested:

> >     >>> im = Image.open(filename)
> >     >>> im.filename = None # disable mapping
> >     >>> im.load()
> >     >>> im.histogram()

(this is likely to give you another error message, though)

you can ask PIL to read everything except the last line from the file, by
modifying the size and tile attributes before you call any other method:

    >>> im = Image.open(...)
    >>> im.size = (40320, 14673-1)
    >>> im.tile = [('raw', (0, 0, 40320, 14673-1), 18L, ('L', 0, 1))]

</F>






More information about the Image-SIG mailing list