[mapserver-users] How to make label background transparent?

Stephen Woodbridge stephenwoodbridge37 at gmail.com
Mon Mar 11 08:24:46 PDT 2019


Hi Lars,

Thank you for the feedback on this. Let me clarify what I'm trying to 
do. I have a shape file with contour lines in it. I drawing this as an 
overlay image so the background is transparent. In the mapfile the 
IMAGECOLOR sets the background color and this is the color that is 
identified as transparent. So in a PNG image the background color is set 
in the first slot of the color table and marked as transparent. In my 
case this is color #ffffff, but if I create labelpoly and assign it as 
#ffffff then another slot in the color table is allocated and assigned 
the color #ffffff but not the first slot that was allocated for the 
background, so it shows up as white.

In my image I have a contour line drawn and when it is labeled the 
contour line goes through the text of the label. If I use the labelpoly 
then a white background for the label is shown hiding the contour line. 
This is what I want to happen only I want the labelpoly color to be the 
same color slot as the background color to it hides the contour line 
behind the label like the white case but is transparent instead of 
white. IE: it needs to write the label poly with the first slot color, 
not the new white color slot.

I think, setting the COLOR -1 -1 -1 was intended to do this, but maybe not.

Attached are two small images:

contour.png - shows the contour line through the label text with 
labelpoly color #FFFFFF00 or color -1 -1 -1
contour-white.png - show labelpoly color #FFFFFF

-Steve W

On 3/11/2019 5:25 AM, lars.schylberg at blixtmail.se wrote:
> Hi Steve,
>
> I am not sure what your use of IMAGECOLOR has to do here.  Normally I have some layers in between the
> background and the elevation lines.
>
> But there are two more ways do get the color to be transparent in Mapserver:
>
> STYLE
>    GEOMTRANSFORM 'labelpoly'
>    COLOR "#ffffff00"
> END
>
> or
>
> STYLE
>    GEOMTRANSFORM 'labelpoly'
>    COLOR 255 255 255
>    OPACITY 0
> END
>
>
> But those are doing the same thing as your solution below with COLOR -1 -1 -1
>
> Maybe You are after some of the potential techniques that Thomas talked about a couple of years ago with
> layer blending with the label cache. Those were some future techniques that could be added to the
> layer composite pipeline if anyone was interested.
>
> Best regards
>
> Lars Schylberg



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: contour.png
Type: image/png
Size: 3281 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20190311/584cf897/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: contour-white.png
Type: image/png
Size: 2501 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20190311/584cf897/attachment-0001.png>


More information about the mapserver-users mailing list