Imagerotate然后与目标图像的中心对齐

Right now my rotated image gets justified to the left and top of my destination image. The behavior I want is for the center of the rotated image to be centered on the destination image. The degree of rotation is dynamic. The $center_pt is the center point of my destination. I've been looking online for a day and a half but there must be a way!

$destination_image = 960; //960px x 960px
rotated image = 640px x 640px; // ($rotate & $rotate_me, same thing)
$center_pt = center of destination image

$rotate_me = imagecreatefrompng("myimage.png"); 
$rotate = imagerotate($rotate_me, $dynamicdegree),0);
imagesettile($im, $rotate);
imagefilledellipse($destination_image, $center_pt, $center_pt, $outer_outer_diameter, $outer_outer_diameter,     IMG_COLOR_TILED);

Sorry I prepared an image to share with you but did not have enough reputation to post it.

It was difficult figuring out how to center my image after rotating it because it kept getting justified to the left. Here's what I did, after stripping down a more verbose solution, works perfect!

  $src = imagerotate($rotate,$yournumber,$transColor); //rotated my image
  imagesavealpha($src, true); // alpha thing otherwise there was a black polygon around image

  //the rotation makes your image bigger, usually, so you need to find the new width and height

  $src_x = ImageSX($src); //find out new x width
  $src_y = ImageSY($src); //find out new y height

  $wantedWidth = 640;  //this is the width I want my completed image to be
  $wantedHeight = 640; //this is the height I want my completed image to be

  $src_widthx = $src_x/2 - $wantedWidth/2;  // divide each by 2 and then subtract desired end width from wider rotated width
  $src_heighty = $src_y/2 - $wantedHeight/2;  // and again for height

imagecopy($im, $src, 0, 0, $src_widthx, $src_heighty, 640, 640);  //notice I'm no longer using imagefilledellipse here as imagecopy seems to be more specifically for centering things