[Image-SIG] What is the best way to anti-alias a very large resolution image in PIL

Charlie Clark charlie.clark at clark-consulting.eu
Tue Sep 13 17:58:00 CEST 2011

Hi Craig,

Am 08.09.2011, 13:07 Uhr, schrieb Craig Coleman (C)  
<Craig.Coleman at ordnancesurvey.co.uk>:

> Hi,
> I have a really thorny problem.
> I need to downsample a raster map that is 23622x23622 pixels to
> 7874x7874 pixels using the ANTIALIAS filter.
> I have the following Python code:
>>>> import Image
>>>> img = Image.open(r"C:\temp\24bit_nd.tif")
>>>> nimg = img.resize((7874,7874),Image.ANTIALIAS)
> As soon as the resize method is called, python crashes instantly.  I
> presume this is a memory allocation issue.

I think you may be right. Do you have the full traceback the error  

Is this using a 32-bit version of Python? Do you have access to a 64-bit  
system? For MS Windows there is a 64-bit PIL installer:


> Is there another way of performing anti-aliasing on such a large image
> (its 2.7GB uncompressed although I'm using LZW for storage).

> I have tried converting the file to 8bit with a palette and this
> successfully downsamples but the ANTIALIAS is not performed.  What am I
> doing wrong?

Charlie Clark
Managing Director
Clark Consulting & Research
German Office
Helmholtzstr. 20
D- 40215
Tel: +49-211-600-3657
Mobile: +49-178-782-6226

More information about the Image-SIG mailing list