[mapserver-users] transparent pixmaps in python mapscripts

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


Thanks Dan, I am plopping it on an air photo, so I don't think that your
approach will work.  

David.

-----Original Message-----
From: mapserver-users-bounces at lists.osgeo.org
[mailto:mapserver-users-bounces at lists.osgeo.org] On Behalf Of Dan Little
Sent: Wednesday, September 24, 2008 10:02 AM
To: Daniel Morissette; Fawcett, David
Cc: mapserver-users at lists.osgeo.org
Subject: Re: [mapserver-users] transparent pixmaps in python mapscripts


You could render the map with a known background color, and then use PIL
to create a transparent GIF from the image.

If you can use white as the bg color then you can convert the image to a
2 color bitmap in memory, and then use it as a mask to perform the
transparency composition.



----- Original Message ----
> From: Daniel Morissette <dmorissette at mapgears.com>
> To: "Fawcett, David" <David.Fawcett at state.mn.us>
> Cc: mapserver-users at lists.osgeo.org
> Sent: Wednesday, September 24, 2008 8:45:19 AM
> 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/
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users



      
_______________________________________________
mapserver-users mailing list
mapserver-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users



More information about the MapServer-users mailing list