[OSM-dev] NOT-saving empty Mapnik tiles
Igor Podolskiy
igor.podolskiy at vwi-stuttgart.de
Fri Aug 12 19:02:27 BST 2011
Hi Markus,
sorry, I misread your first mail, it's not a PIL.Image but a
mapnik.Image - it doesn't have all those fancy methods of a PIL Image. I
don't know how to convert from mapnik to PIL now, either :( My fault.
But I just had another idea.
If your current method works for you and it's just about reducing disk
IO, you just could use StringIO [1] or the like and save the PNG image
to a buffer first, then check its length and conditionally save it to disk:
import StringIO
buf = StringIO.StringIO()
# ... render the image somehow here ...
im.save(buf, 'png256')
if buf.len > 116:
f = open(tile_name, 'wb')
f.write(buf.getvalue())
f.close()
buf.close()
Bye
Igor
[1] http://docs.python.org/library/stringio.html
More information about the dev
mailing list