[MS4W-Users] transparency with php mapscript

Sven Schroeter schroeter at netgis.de
Tue May 21 06:41:34 EDT 2019

Hi Jeff,

I'm fighting with the SWIG MapScript Opacity again and found a very 
strange behavior.

Here is my test script:

$map = new mapObj(MAPFILE_PATH.'test.map');

// set image format
$oRasterLayer = $map->getLayerByName('tk_rlp_tms_grau');
$oPolyLayer = $map->getLayerByName('grenzen_vg');

$oRasterLayer->status = MS_ON;

$oPolyLayer->status = MS_ON;

// set image size

// Bild im MapServer IMAGEPATH abspeichern.
$image = $map->draw();

//Bildname, Extension und Pfad
$picname = md5(rand());
$picext = ".jpeg";

$picpathname = MS_TMP_PATH.$picname.$picext;

// Bild im MapServer IMAGEPATH abspeichern.
$mapimage = $image->save($picpathname,$map); //URL

$imgurl = MS_TMP_URL.$picname.$picext;

//header('Location: '.$imgurl);

echo '<img src="'.$imgurl.'" border="1">';

If I set the width of the image to a number with 2 zeros at the end 
everything works fine.
e.g. $map->setsize(800,814);
or $map->setsize(1000,768);

as soon as I change the value for the width of the image it often 
doesn't work anymore and the layers don't have transparency anymore.
e.g. $map->setsize(801,814);
or $map->setsize(1011,768);

It is extremely difficult to see a pattern here.
All variants work with the old Mapscript.
Is this a bug?


Am 16.05.2019 um 13:57 schrieb Jeff McKenna via MS4W-Users:
> I forgot to mention that that test script uses an important trick to 
> test: it saves the mapfile to a temporary file, where you can confirm 
> that a COMPOSITE object is indeed created (here is that script again 
> https://ms4w.com/trac/wiki/SWIGMapScriptOpacity )
> -jeff
> -- 
> Thank you for using MS4W.
> "MS4W: open doors as well as windows"

More information about the MS4W-Users mailing list