[mapserver-users] How to make label background transparent?
Stephen Woodbridge
stephenwoodbridge37 at gmail.com
Tue Mar 12 12:55:01 PDT 2019
OK, I'm start to think this is a bug.
Attached is a test.map and junk.png which is generated using shp2img -m
test.map -o junk.png
You will have to adjust the FONTSET and LABEL FONT arial for your system.
What I'm trying to get is is the output of junk.png where the white is
transparent like the image background.
I upgraded to:
MapServer version 7.0.4 OUTPUT=PNG OUTPUT=JPEG OUTPUT=KML SUPPORTS=PROJ
SUPPORTS=AGG SUPPORTS=FREETYPE SUPPORTS=CAIRO SUPPORTS=SVG_SYMBOLS
SUPPORTS=RSVG SUPPORTS=ICONV SUPPORTS=FRIBIDI SUPPORTS=WMS_SERVER
SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT
SUPPORTS=WCS_SERVER SUPPORTS=SOS_SERVER SUPPORTS=FASTCGI
SUPPORTS=THREADS SUPPORTS=GEOS INPUT=JPEG INPUT=POSTGIS INPUT=OGR
INPUT=GDAL INPUT=SHAPEFILE
which is the latest in UbuntuGIS for Xenial. I don't see this in the
list of changes from 7.0.4 to 7.0.7 but it might be a small issue that
didn't make the release notes.
-Steve
On 3/11/2019 1:58 PM, Basques, Bob (CI-StPaul) wrote:
> i have an example of a working label as described.
>
> looks like this for output
>
> https://www.pwgeo.org/apps/compass/#xy=154857.26601255,567003.50321715,17.80183737240048&on=L167/all;L207/all;L117/all;L116/all;L280/all
>
> i'm not in the office today though to get at it.
>
> bobb
>
> ________________________________
> From: mapserver-users <mapserver-users-bounces at lists.osgeo.org> on behalf of Schylberg Lars <lars.schylberg at saabgroup.com>
> Sent: Monday, March 11, 2019 11:23:07 AM
> To: Stephen Woodbridge; mapserver-users
> Subject: Re: [mapserver-users] How to make label background transparent?
>
> Hi again,
>
> What happens if You skip the IMAGECOLOR statement ?
> I did a project a year ago with a lot of transparent layers.
> But I can't see that I used any IMAGECOLOR statements in that case.
> I did however use predefined 256 color palettes for another reason.
>
> /Lars
>
> -----Original Message-----
> From: mapserver-users <mapserver-users-bounces at lists.osgeo.org> On Behalf Of Stephen Woodbridge
> Sent: den 11 mars 2019 16:25
> To: lars.schylberg at blixtmail.se; mapserver-users <mapserver-users at lists.osgeo.org>
> Subject: Re: [mapserver-users] How to make label background transparent?
>
> 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
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/mapserver-users
-------------- next part --------------
MAP
STATUS ON
SIZE 500 500
EXTENT 0 0 500 500
TRANSPARENT ON
IMAGECOLOR 255 255 255
IMAGETYPE PNG
FONTSET "/maps/wms/fonts/font.list"
LAYER
STATUS DEFAULT
NAME 'test'
TYPE LINE
FEATURE
WKT "LINESTRING(0 0,500 500)"
TEXT "123.456"
END
CLASS
STYLE
COLOR "#000000"
WIDTH 3
END
LABEL
TYPE TRUETYPE
FONT arial
COLOR "#000000"
OUTLINECOLOR 255 255 255
ANTIALIAS FALSE
OUTLINEWIDTH 3
SIZE 14
POSITION CC
END
END
END
LAYER
STATUS DEFAULT
NAME 'test'
TYPE LINE
FEATURE
WKT "LINESTRING(0 50,500 550)"
TEXT "123.456"
END
CLASS
STYLE
COLOR "#000000"
WIDTH 3
END
LABEL
STYLE
GEOMTRANSFORM 'labelpoly'
COLOR 255 255 255
END
TYPE TRUETYPE
FONT arial
COLOR "#000000"
ANTIALIAS FALSE
SIZE 14
POSITION CC
END
END
END
END
-------------- next part --------------
A non-text attachment was scrubbed...
Name: junk.png
Type: image/png
Size: 6448 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20190312/fb80a60a/attachment.png>
More information about the MapServer-users
mailing list