get("width"); $height = $obj1->get("height"); //calculate rotated dimensions $neededWidth = round(abs(sin(deg2rad($angle))*$height)+abs(cos(deg2rad($angle))*$width)); $neededHeight = round(abs(sin(deg2rad($angle))*$width)+abs(cos(deg2rad($angle))*$height)); //modify requests for($i=0; $iset("width", $neededWidth); $obj->set("height", $neededHeight); $map_extent = $obj->get("BBOX"); $coord = split(",",$map_extent); $coord = $this->enlargeExtent($coord, $width, $height, $neededWidth, $neededHeight); $obj->set("BBOX", implode(",", $coord)); $url[$i] = $obj->url; } //get image $urls = implode("___", $url); $this->weldMaps2PNG($urls, $filename, $encode); //rotate image $imagick = new Imagick(); $imagick->readImage($filename); $imagick->rotateImage(new ImagickPixel(), $angle); //get the new dimensions $imgWidth = $imagick->getImageWidth(); $imgHeight = $imagick->getImageHeight(); //crop empty areas $imagick->cropImage($width, $height, ($imgWidth-$width)/2, ($imgHeight-$height)/2); //write modified image $imagick->writeImage(); $image = imagecreatefrompng($filename); imagepng($image,$filename); } function enlargeExtent($coordArray, $oldWidth, $oldHeight, $newWidth, $newHeight){ $extentx = ($coordArray[2] - $coordArray[0]); $extenty = ($coordArray[3] - $coordArray[1]); $coordArray[0]+=($extentx/$oldWidth)*($oldWidth-$newWidth)/2; $coordArray[2]+=($extentx/$oldWidth)*($newWidth-$oldWidth)/2; $coordArray[1]+=($extenty/$oldHeight)*($oldHeight-$newHeight)/2; $coordArray[3]+=($extenty/$oldHeight)*($newHeight-$oldHeight)/2; return $coordArray; } } ?>