On 01.09.2010 11:17, [email protected] wrote:
Hi,

I'll just patch mapnik's ogcserver (if you are using it, of course). We are 
using a copy of ogcserver for each wms service instead of a global installed 
one. This means there is no problem in doing such an ugly hack :) because it 
will affect just that service.

The image won't hit the disk until cached and it will also save you the hassle 
of running a script afterwards. Tell me if the performance is acceptable, 
perhaps we can make a patch until support is added to mapnik.

File common.py:

class WMSBaseServiceHandler(BaseServiceHandler):

     def GetMap(self, params):
         m = self._buildMap(params)
         im = Image(params['width'], params['height'])
         render(m, im)
         format = PIL_TYPE_MAPPING[params['format']]
         import PIL, StringIO
         img = PIL.Image.open(StringIO.StringIO(im.tostring(format)))
         img = self.reduce_opacity(img, 0.5)
         buf = StringIO.StringIO()
         img.save(buf, format=format)
         return Response(params['format'].replace('8',''), buf.getvalue())

     def reduce_opacity(self, im, opacity):
         import ImageEnhance
         """Returns an image with reduced opacity."""
         assert opacity>= 0 and opacity<= 1
         if im.mode != 'RGBA':
             im = im.convert('RGBA')
         else:
             im = im.copy()
         alpha = im.split()[3]
         alpha = ImageEnhance.Brightness(alpha).enhance(opacity)
         im.putalpha(alpha)
         return im



Hi,

i've actually done something similar, customized rendering pipeline to check whether final rendering should be transparent or not.

Would it be feasible to add this kinda support directly to mapnik core?

Dražen
_______________________________________________
Mapnik-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/mapnik-users

Reply via email to