[OSM-dev] NOT-saving empty Mapnik tiles

Igor Podolskiy igor.podolskiy at vwi-stuttgart.de
Fri Aug 12 18:36:28 BST 2011

Hi Markus,

> Is there a function like im.is_empty() ?
um, what is your definition of "empty" exactly? Is it "all pixels are 
transparent"? Or is it "all pixels are of the same color"? Or is it "all 
pixels are of color X"? I don't think there's an Image.is_empty() 
because "empty" means different things to different people.

There are different ways to do that depending on the definition. You can 
loop over the image pixels with im.getdata() and check some property of 
an image, or you might want to take a look on im.getcolors() dictionary 
which tells you how often a color occurs in the image. There's PIL 
documentation for all the Image methods here: [1].

If you have difficulties writing that down in Python, I'd be happy to 
help - just drop me a line here.


[1] http://www.pythonware.com/library/pil/handbook/image.htm

More information about the dev mailing list