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 = explode(",",$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, $opacities); //rotate image $imagick = new Imagick(); $imagick->readImage($filename); $imagick->rotateImage(new ImagickPixel('transparent'), $angle); // //get the new dimensions // $imgWidth = $imagick->getImageWidth(); // $imgHeight = $imagick->getImageHeight(); // //crop empty areas // $imagick->cropImage($width, $height, ($imgWidth-$width)/2, ($imgHeight-$height)/2); orig imagick bug? $imagick->cropImage($width, $height, ($neededWidth-$width)/2, ($neededHeight-$height)/2); //write modified image $imagick->writeImage($filename); $image = imagecreatefrompng($filename); imagepng($image,$filename); } /** * Old constructor to keep PHP downward compatibility */ function weldMaps2PNG_rotate($urls,$filename, $angle, $encode = true, $opacities = ""){ self::__construct($urls,$filename, $angle, $encode, $opacities); } 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; } } ?>