[Image-SIG] Re: Speed of Image.crop

Fredrik Lundh fredrik at pythonware.com
Mon Oct 18 20:32:06 CEST 2004


Kenji YOKOI wrote

> I am trying to draw a cropped image from a larger image smoothly every frame. Essentially there is 
> no problem to crop a image (image.crop) every frame even at 140Hz (about 7ms). But, when the 
> cropping size exceeds 512x512, the cropping performance suddenly drops to 50ms or more. This 
> situation was confirmed under Windows2000 and Mac OSX 10.3. Is this a PIL problem or a hardware 
> problem (such as a video card or AGP bus speed) ?

are we talking about color images?

if so, you're actually hitting a limit in PIL: the internal storage module
switches allocation strategy for images that need more than 1 mega-
byte of storage.  It's unlikely that the alternate storage strategy can
explain a 7x performance drop, but one never knows...

to see if this is the problem, you have to edit the libImaging/Storage.c
file.  change

#define THRESHOLD 1048576L

to, say,

#define THRESHOLD 4*1048576L


and rebuild.

(I should probably increase the threshold in 1.1.5 final; PIL's almost
10 years old, so parameters like this could need some tuning...)

</F> 





More information about the Image-SIG mailing list