[MapProxy] Multi-layer transparency problem

DeDuikertjes DeDuikertjes at xs4all.nl
Mon Jan 16 13:37:26 EST 2012


Dejan,

I've created this patch which helps when mapproxy has to overlay 
multiple layers with opacity and an alpha channel.
Maybe something along these lines can help you as well:

mapproxy/image/__init__.py:
     layer_img = layer.as_image()
     if (layer.image_opts and layer.image_opts.opacity is not None
         and layer.image_opts.opacity < 1.0):
-        layer_img = layer_img.convert(img.mode)
-        img = Image.blend(img, layer_img, layer.image_opts.opacity)
+        if layer_img.mode == 'RGBA':
+            alpha = layer_img.split()[3]
+            alpha = 
ImageEnhance.Brightness(alpha).enhance(layer.image_opts.opacity)
+            layer_img.putalpha(alpha)
+            img.paste(layer_img, (0, 0), layer_img)
+        else:
+            layer_img = layer_img.convert(img.mode)
+            img = Image.blend(img, layer_img, layer.image_opts.opacity)
     else:
         if layer_img.mode == 'RGBA':
             # paste w transparency mask from layer

mapproxy/platform/image.py:
Everywhere I've substituted:
Image, ImageColor, ImageDraw, ImageFont, ImagePalette, ImageChops
by:
Image, ImageColor, ImageDraw, ImageFont, ImagePalette, ImageChops, 
ImageEnhance

@Oliver: is there any chance that this patch will become part of mapproxy?
Do I have to do something for that?

MArco



Op 16-1-2012 18:00, mapproxy-request at lists.osgeo.org schreef:
> Re: [MapProxy] Multi-layer transparency problem


More information about the MapProxy mailing list