[MapProxy] more opacity questions
DeDuikertjes
DeDuikertjes at xs4all.nl
Tue Jan 10 10:12:24 EST 2012
Oliver,
Thank you for the help.
I've tested this option:
Can these PIL problems be mitigated by having the source WMS serve images on a white background and set mapproxy transparency color to white?
That didn't work for me.
So I've bitten the bullet and tried to implement the desired behaviour
in mapproxy.
With this patch on /image/__init__.py and corresponding import of
ImageEnhance in /platform/image.py this actually works for me.
Perhaps this is usable in a future version of Mapproxy?
.
By the way I'm not sure I've handled the image mode correctly. Any
advice appreciated.
Greetings, MArco
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
Op 10-1-2012 13:55, Oliver Tonnhofer schreef:
> On 08.01.2012, at 18:00, DeDuikertjes wrote:
>> Does this limitation of PIL mean that if the source wms serves images with transparency AND semi transparent features (and Mapproxy config does NOT have any transparency settings) the result of a multi-layer request will have these problems?
> No, MapProxy uses paste() instead of blend() in this case and paste() regards the existing alpha channel.
>
>> Can these PIL problems be mitigated by having the source WMS serve images on a white background and set mapproxy transparency color to white?
> It might work, but I haven't looked at the code.
>
> Regards,
> Oliver
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapproxy/attachments/20120110/b25a6d90/attachment.html
More information about the MapProxy
mailing list