[mapserver-users] transparent pixmaps in python mapscripts

Daniel Morissette dmorissette at mapgears.com
Wed Sep 24 09:45:19 EDT 2008


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