mapnik-org/mapnik — Issue #182: Prevent initialization of mapnik.Image prior to mapnik.Render
Author: artemp
Created: 2011-10-11 07:40:46+00:00
State: open
Labels: Agg_Renderer

When rendering to an existing Image object, mapnik seems to first initialize the contents to 0x00000000. Can it be more accepting of Image contents so that multi-pass renders can happen? See attached images (esp. ''expected.jpg'') for input and output of this python snippet. Incidentally it would also be nice for Image objects to have a ''fromstring()'' method matching the existing ''tostring()''.

{{{
#!python
import mapnik
import PIL.Image

if __name__ == '__main__':

img = mapnik.Image.open('base.jpg')
stylesheet, output = 'style.xml', 'actual.png'

# ...snip...

map = mapnik.Map(width, height)
mapnik.load_map(map, stylesheet)
map.zoom_to_box(mapnik.Envelope(left, top, right, bottom))

mapnik.render(map, img)
img = PIL.Image.fromstring('RGBA', (width, height), img.tostring())
img.save(output, quality=85)
}}}