the maprequests seperated by three underscores */ function weldMaps2PNG($urls, $filename){ if(!$urls || $urls == ""){ $e = new mb_exception("weldMaps2PNG: no maprequests delivered"); } // getting the array of urls $url = explode("___", $urls); // make url parameters accessible $obj1 = new stripRequest($url[0]); $width = $obj1->get("width"); $height = $obj1->get("height"); // create output image $image = imagecreatetruecolor($width, $height); // assign a white background color $white = ImageColorAllocate($image,255,255,255); ImageFilledRectangle($image,0,0,$width,$height,$white); // iterate over each request for($i=0; $isetPNG(); $url[$i] = $obj->encodeGET(); // get temporary image for this URL $img = $this->loadpng($url[$i]); if($img != false){ // copy temporary image over already assigned images imagecopy($image, $img, 0, 0, 0, 0, $width, $height); imagedestroy($img); } else{ $e = new mb_exception("weldMaps2PNG: unable to copy image: " . $url[$i]); } } // output the image to the filesystem /** * @todo different outputs? */ imagepng($image,$filename); imagedestroy($image); } /** * Helper function to generate temporary images for each URL * * @param a single URL which represents a maprequest */ function loadpng ($imgurl) { $obj = new stripRequest($imgurl); $f = $obj->get("format"); /** * react on format * @todo create switch? * @todo handle as reg-exp? * @todo instanciate $im as false or null? */ if(mb_strtolower($f) == 'image/png' || mb_strtolower($f) == 'png'){ $im = @ImageCreateFromPNG($imgurl); } if(mb_strtolower($f) == 'image/jpeg' || mb_strtolower($f) == 'jpeg'){ $im = @ImageCreateFromJPEG($imgurl); } if(mb_strtolower($f) == 'image/gif' || mb_strtolower($f) == 'gif'){ $im = @ImageCreateFromGIF($imgurl); } if(!$im){ $im = false; $e = new mb_exception("weldMaps2PNG: unable to load image: ".$imgurl); } // return the temporary image return $im; } } // eof class weldMaps2PNG ?>