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 <[EMAIL PROTECTED]> > To: "Fawcett, David" <[EMAIL PROTECTED]> > Cc: [email protected] > 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 > > [email protected] > > http://lists.osgeo.org/mailman/listinfo/mapserver-users > > > -- > Daniel Morissette > http://www.mapgears.com/ > _______________________________________________ > mapserver-users mailing list > [email protected] > http://lists.osgeo.org/mailman/listinfo/mapserver-users _______________________________________________ mapserver-users mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/mapserver-users
