<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <font size="-1">Oliver,<br>
      <br>
      Thank you for the help.<br>
      I've tested this option:<br>
    </font>
    <blockquote>
      <pre wrap=""><small>Can these PIL problems be mitigated by having the source WMS serve images on a white background and set mapproxy transparency color to white?</small></pre>
    </blockquote>
    <small>That didn't work for me.<br>
      <br>
      So I've bitten the bullet and tried to implement the desired
      behaviour in mapproxy. <br>
      With this patch on /image/__init__.py</small> <small>and
      corresponding import of&nbsp; </small><small>ImageEnhance </small><small>in
      /platform/image.py this actually works for me.</small><br>
    <small></small><br>
    <small>Perhaps this is usable in a future version of Mapproxy?<br>
      .<br>
      By the way I'm not sure I've handled the image mode correctly. Any
      advice appreciated.<br>
      <br>
      Greetings, MArco<br>
      <br>
      layer_img = layer.as_image()<br>
      if (layer.image_opts and layer.image_opts.opacity is not None<br>
      &nbsp;&nbsp;&nbsp; and layer.image_opts.opacity &lt; 1.0):<br>
      <br>
      - layer_img = layer_img.convert(img.mode)<br>
      - img = Image.blend(img, layer_img, layer.image_opts.opacity)<br>
      +&nbsp;&nbsp;&nbsp; if layer_img.mode == 'RGBA':<br>
      +&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; alpha = layer_img.split()[3]<br>
      +&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; alpha =
      ImageEnhance.Brightness(alpha).enhance(layer.image_opts.opacity)<br>
      +&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; layer_img.putalpha(alpha)<br>
      +&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; img.paste(layer_img, (0, 0), layer_img)<br>
      +&nbsp;&nbsp;&nbsp; else:<br>
      +&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; layer_img = layer_img.convert(img.mode)<br>
      +&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; img = Image.blend(img, layer_img,
      layer.image_opts.opacity)<br>
      <br>
      else:<br>
      &nbsp;&nbsp;&nbsp; if layer_img.mode == 'RGBA':<br>
      &nbsp;&nbsp;&nbsp; # paste w transparency mask from layer<br>
    </small><br>
    <br>
    <br>
    Op 10-1-2012 13:55, Oliver Tonnhofer schreef:
    <blockquote
      cite="mid:2F3526B8-DB24-41D2-9C82-F3742301B6E1@omniscale.de"
      type="cite">
      <pre wrap="">
On 08.01.2012, at 18:00, DeDuikertjes wrote:
</pre>
      <blockquote type="cite">
        <pre wrap="">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?
</pre>
      </blockquote>
      <pre wrap="">
No, MapProxy uses paste() instead of blend() in this case and paste() regards the existing alpha channel.

</pre>
      <blockquote type="cite">
        <pre wrap="">Can these PIL problems be mitigated by having the source WMS serve images on a white background and set mapproxy transparency color to white?
</pre>
      </blockquote>
      <pre wrap="">
It might work, but I haven't looked at the code.

Regards,
Oliver

</pre>
    </blockquote>
  </body>
</html>