[mapserver-users] transparent pixmaps in python mapscripts

Fawcett, David David.Fawcett at state.mn.us
Wed Sep 24 11:59:00 PDT 2008


Thanks Daniel, 

I am not calling layer.draw(), just map.draw().

David.

-----Original Message-----
From: Daniel Morissette [mailto:dmorissette at mapgears.com] 
Sent: Wednesday, September 24, 2008 8:45 AM
To: Fawcett, David
Cc: mapserver-users at lists.osgeo.org
Subject: Re: [mapserver-users] transparent pixmaps in python mapscripts


David,

TRANSPARENCY ALPHA works only between layers drawn using map.draw() in a

single pass. If you call layer.draw() for each layer in a loop in your 
script then TRANSPARENCY ALPHA has no effect and that could explain the 
problem you are encountering.

Daniel


Fawcett, David wrote:
> I am using a pixmap symbol to mark a point using Python MapScript v. 
> 5.2.
>  
> The image has a transparent background.  When I use the symbol with
> MapServer CGI, I the transparency works.  When I use the symbol in 
> MapScript, I get a black background for the symbol, no transparency. 
>  
> Here is how I am creating the symbol:
>  
> img = mapscript.imageObj(/symbols/redcross.png', 'GD/PNG')
>  
> # create the symbol using the image
> symbol = mapscript.symbolObj('from_img')
> symbol.type = mapscript.MS_SYMBOL_PIXMAP
> symbol.setImage(img)
> symbol_index = mymap.symbolset.appendSymbol(symbol)
>  
> I also tried to add this to the layer, but it made no difference 
> either: inline_layer.transparency = mapscript.MS_GD_ALPHA
>  
> Here is a gdalinfo report on the symbol image:
>  
> Driver: PNG/Portable Network Graphics
> Files: redcross.png
> Size is 32, 32
> Coordinate System is `'
> Image Structure Metadata:
>   INTERLEAVE=PIXEL
> Corner Coordinates:
> Upper Left  (    0.0,    0.0)
> Lower Left  (    0.0,   32.0)
> Upper Right (   32.0,    0.0)
> Lower Right (   32.0,   32.0)
> Center      (   16.0,   16.0)
> Band 1 Block=32x1 Type=Byte, ColorInterp=Red
>   Mask Flags: PER_DATASET ALPHA
> Band 2 Block=32x1 Type=Byte, ColorInterp=Green
>   Mask Flags: PER_DATASET ALPHA
> Band 3 Block=32x1 Type=Byte, ColorInterp=Blue
>   Mask Flags: PER_DATASET ALPHA
> Band 4 Block=32x1 Type=Byte, ColorInterp=Alpha
>  
> Any ideas on how to get a pixmap symbol with a transparent background
> using python mapscript? 
>  
> Thanks,
>  
> David.
>  
>  
>  
> 
> 
> ----------------------------------------------------------------------
> --
> 
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org 
> http://lists.osgeo.org/mailman/listinfo/mapserver-users


-- 
Daniel Morissette
http://www.mapgears.com/



More information about the MapServer-users mailing list