Hi Igor, thank you, this link is very helpful!
> 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. Sorry, my fault. :-) I want to determine if an image has transparent pixels only. If yes I would like to dispose it because nobody could see it anyway. Would save disk space - and inodes... -------- Original-Nachricht -------- > Datum: Fri, 12 Aug 2011 19:36:28 +0200 > Von: Igor Podolskiy <[email protected]> > An: [email protected], [email protected] > Betreff: Re: [OSM-dev] NOT-saving empty Mapnik tiles > 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. > > Bye > Igor > > [1] http://www.pythonware.com/library/pil/handbook/image.htm _______________________________________________ dev mailing list [email protected] http://lists.openstreetmap.org/listinfo/dev

