[mapserver-dev] RE: [mapserver-users] mapserver vs mapscript: agg + transparency + quantize not working

Tiemens, Gerben Gerben.Tiemens at grontmij.nl
Fri Nov 6 03:29:57 EST 2009


 
Drilled down further to the problem.

I use ImageObj.getBytes()  to get the bytearray and then save the png in an other part of my code.
However, the getBytes() method uses the msSaveImageBufferGD()  even when my imageObj/mapObj  uses an outputformat with AGG.
This results in an error in the new beta  (5.6.0 beta 5) with the message: 

-		base	{"getBytes: General error message. Failed to get image buffer;msSaveImageBufferGD(): Image handling error. Unknown output image type driver: gd/."}	System.Exception {System.ApplicationException}


In previous versions the error was not given, but just went further with making a crippled image.

Is there an other method to save the bytearray of an AGG image?

Greetings

Gerben


-----Oorspronkelijk bericht-----
Van: mapserver-users-bounces at lists.osgeo.org [mailto:mapserver-users-bounces at lists.osgeo.org] Namens Tiemens, Gerben
Verzonden: Thursday, November 05, 2009 9:01 PM
Aan: Roger André
CC: mapser all users
Onderwerp: RE: [mapserver-users] mapserver vs mapscript: agg + transparency + quantize not working


Thanks for your reply Roger André,

But i specified my own outputformat in mapscript.
When using this outputformat without the quantize options, the image comes out as wished and configured. (transparent and fullcolor) When using this outputformat with the quantize options on:
-with the CGI mapserv.exe (and the saved mapfile from mapscript) the image is as configured. (transparent and all needed colors in a small png) -with mapscript, the mapobj.draw(), the image is crippled and not as wished.(not transparent, black lines are  strange and labels are disapearing)  It should be equal to CGI.

I do'nt know why this difference between mapscript and mapserv.exe exists with the same configuration of mapfile.

Has someone an idea?
I tested this on MS4W  2.29 (mapserver 5.2.0) and MS4W 3.0 (mapserver 5.4.2)

Greetings
Gerben


________________________________________
Van: Roger André [randre at gmail.com]
Verzonden: donderdag 5 november 2009 19:55
Aan: Tiemens, Gerben
CC: mapser all users
Onderwerp: Re: [mapserver-users] mapserver vs mapscript: agg + transparency +   quantize not working

Hi Tiemens,

Not sure if this helps, but in some of the testing I did with Python mapscript, I specified the following in my code:

map.selectOutputFormat("AGGPNG24")

That seemed to do the trick for me.  The script is inline below, in case it might help give context.

Roger
--
#! /usr/bin/python

# mimic the Mapnik 'hello world' at
# http://trac.mapnik.org/wiki/GettingStarted
# based on example in Web Mapping Illustrated

import mapscript

# create a base mapfile
map = mapscript.mapObj()
map.selectOutputFormat("AGGPNG24")
map.name<http://map.name> = "CustomMap"
map.setSize(1000, 500)
#map.setExtent(-180.0, -90.0, 180.0, 90.0) map.setExtent(-22, -36, 60, 38)
map.imagecolor.setRGB(70,130,180)
map.units = mapscript.MS_DD

# set Web image params
map.web.imagepath = "/var/www/tmp/"
map.web.imageurl = "/tmp"

# create layer object
layer = mapscript.layerObj(map)
layer.name<http://layer.name> = "countries"
#layer.type = mapscript.MS_LAYER_LINE
layer.type = mapscript.MS_LAYER_POLYGON
layer.status = mapscript.MS_DEFAULT
layer.data = "/home/randre/gis_data/unep/unep_coastlines.shp"
layer.template = "template.html"

# create a class
class1 = mapscript.classObj(layer)
class1.name<http://class1.name> = "Countries"

# create a style
style = mapscript.styleObj(class1)
style.outlinecolor.setRGB(125,125,125)
style.width = 1
style.color.setRGB(240,240,240)
#style.antialias = mapscript.MS_TRUE

# write the map object into a map file
#map.save("custom.map")

# write out an image using these params
mapimage = map.draw()
mapimage.save("ms_world.png")
--
On Thu, Nov 5, 2009 at 9:04 AM, Tiemens, Gerben <Gerben.Tiemens at grontmij.nl<mailto:Gerben.Tiemens at grontmij.nl>> wrote:

I am busy writing a application with mapscript in C#.

Currently I am facing the earlier mentioned problems of agg + transparent images + quantization.

Is the new MS4W compiled with the quantization options?

The image background is now Black. The labels are dissapearing.

It should be an image wich is completly transparent with some colored lines and some black labels.

Setting the imagecolor will not help me.

Images without quantization options on, are perfect and beautiful png's.



What I am using now is this:

MS4W 3.0 Beta 7   which contains Mapserver 5.4.2



C# mapscript



Mapfile is completely written in C#, so all default options apply.

I saved this mapfile from my mapobj



----------------------

MAP

EXTENT 104952 495303 105452 495803

IMAGECOLOR 255 255 255

IMAGETYPE gif

SIZE 2000 2000

STATUS ON

UNITS METERS

NAME "MS"

OUTPUTFORMAT

NAME "PNG_mapscript"

MIMETYPE "image/png; mode=24bit"

DRIVER "AGG/PNG"

EXTENSION "PNG"

IMAGEMODE "RGBA"

TRANSPARENT TRUE

FORMATOPTION "QUANTIZE_FORCE=on"

FORMATOPTION "QUANTIZE_DITHER=off"

FORMATOPTION "QUANTIZE_COLORS=256"

END

SYMBOL

NAME "circle"

TYPE ELLIPSE

FILLED TRUE

POINTS

1 1

END

END

--

*snip*

--

END



----------------------------------------



In addition to above: further testing revealed that the transparent color is always black.



So if I set

imagecolor 99 99 99

transparent = true

And outputformat to:

OUTPUTFORMAT

NAME "PNG_mapscript"

MIMETYPE "image/png"

DRIVER "GD/PNG"

EXTENSION "PNG"

IMAGEMODE "RGBA"

TRANSPARENT TRUE

FORMATOPTION "QUANTIZE_FORCE=on"

FORMATOPTION "QUANTIZE_COLORS=256"

FORMATOPTION "QUANTIZE_NEW=on"

END

The image appears grey.

The black labels with white backgroundcolor and black shadowcolor in original image are mapped to: white background with gray outline characters and transparent filling and the shadow is grayoutlined with transparent filling. Probably the antialiasing generates the grey outline, the black filling is converted to transparent.

Something is going wrong.



If I set output format to:

OUTPUTFORMAT

NAME "PNG_mapscript"

MIMETYPE "image/png; mode=24bit"

DRIVER "AGG/PNG"

EXTENSION "PNG"

IMAGEMODE "RGBA"

TRANSPARENT TRUE

FORMATOPTION "QUANTIZE_FORCE=on"

FORMATOPTION "QUANTIZE_DITHER=off"

FORMATOPTION "QUANTIZE_COLORS=256"

END

The same applies for the text/labels, but background of the image is now black in all circumstances (no matter what color of imagecolor setting.



---------------------------------------------------



Further research drills down to where the problem may occur:

If i test my saved mapfile from mapscript into the apache/cgi-bin/mapserv.exe

The image is coming out as it should be.

Transparent background, features like it should be, and text also as it should be.,  but if I use the draw() method from mapscript, it comes out crippled.





Am i doing something wrong in mapscript? Are there configurations that I may miss in mapscript that are default in mapserv.exe?

I also do'nt know if this is a problem of Mapserver or MS4W, therefore crossposting it.

Greetings

Gerben



<< Please read our E-mail Disclaimer at: Emaildisclaimer.Grontmij.com<http://Emaildisclaimer.Grontmij.com> >>

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



<< Please read our E-mail Disclaimer at: Emaildisclaimer.Grontmij.com >> _______________________________________________
mapserver-users mailing list
mapserver-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users


More information about the mapserver-dev mailing list