[Image-SIG] [Fwd: reaching memory limits with crop method]

Joao S. O. Bueno Calligaris gwidion at mpc.com.br
Thu Sep 8 16:43:22 CEST 2005


On Thursday 08 September 2005 11:10, Adam J Smith wrote:
> Just following up to see if anyone out there has any thoughts on my
> original post below, as my own research into the issue has not
> gotten me very far. Any help at all will be greatly appreciated.


Hi, 
I've worked with some large tiffs using C and libtiff straigth, in the 
beggining of this year. At this low level one can choose how much of 
an image to read at a time. It is quite harde than doing so in 
Python, but maybe it is the way to go in this case. 

If you want to try it this way, feel free to contact me in private.

To the list: I apologize for suggesting solutions that are not PIL 
(this is the second thread in a row in which I do this). I like PIL, 
I am just suggesting other tools that I had used for similar tasks 
than those asked and which I do not know to acomplish with PIL.

Regards,

	JS
	-><-

>
> ---------------------------- Original Message
> ---------------------------- Subject: reaching memory limits with
> crop method
> From:    "Adam J Smith" <ajs17 at cornell.edu>
> Date:    Wed, August 31, 2005 10:20 am
> To:      image-sig at python.org
> -------------------------------------------------------------------
>-------
>
>
>
> We are encountering memory errors while processing very large
> images (over 3Gb TIFFs, 17888x45408 px). We are trying to make
> "tiles" of the image by calling PIL's crop method and saving the
> resulting images. Eventually, we see this error:
>
> Traceback (most recent call last):
>           File
> "/insitu1/lavers2/ZoomifyImage/ZoomifyFileProcessor.py", line 135,
> in ?
>             processor.ZoomifyProcess(sys.argv[1:])
>           File
> "/insitu1/lavers2/ZoomifyImage/ZoomifyFileProcessor.py", line 127,
> in ZoomifyProcess
>             self.processImage()
>           File "/home/lavers2/ZoomifyImage/ZoomifyBase.py", line
> 199, in processImage
>             imageRow = image.crop([0, ul_y, self.originalWidth,
> lr_y]) File
> "/home/lavers2/python/lib/python2.4/site-packages/PIL/Image.py",
> line 673, in crop
>             self.load()
>           File
> "/home/lavers2/python/lib/python2.4/site-packages/PIL/ImageFile.py"
>, line 155, in load
>             self.load_prepare()
>           File
> "/home/lavers2/python/lib/python2.4/site-packages/PIL/ImageFile.py"
>, line 221, in load_prepare
>             self.im = Image.core.new(self.mode, self.size)
>         MemoryError
>
> This is on a linux box with 2Gb of RAM, 3Gb of swap space, using
> PIL 1.1.4.
>
> As I understand it, the load() method loads the entire image into
> memory, and although there appears to be some ways to stream image
> data through PIL for processing, it looks like you can't use this
> type of approach with the crop() method. Am I wrong about this, or
> is there another way to accomplish the same type of thing (saving a
> region of an image as an image) without using crop()?
>
> Thanks in advance for any guidance you can give.
>
> ____________________________
> adam smith
> ajs17 at cornell.edu
> 255-8893
> 215 ccc
>
>
>
> _______________________________________________
> Image-SIG maillist  -  Image-SIG at python.org
> http://mail.python.org/mailman/listinfo/image-sig


More information about the Image-SIG mailing list