How does php gd center horizontally and vertically?

there is a cloth size of $plat 600x300

I have first put a piece of film into the right 300x300 of this cloth

right

imagecopyresampled($plat, $xxx, 300, 0, 0, 0, 300, 300, 300, 300);

then you want to 300x300 the user"s slices to the left

.

left

imagecopyresampled($plat, $src, 0, 0, 0, 0, 300, 300, $new_w, $new_h);

together, it will be a 600x300.
there is no problem

the question is ~ how to handle the user"s film?
I want to get the horizontal and vertical position of the 300x300 using "uploaded"
and then add it to the plat cloth

$src_w = imagesx($src);
  $src_h = imagesy($src);

  if( $src_w > $src_h){
      $new_w = $src_h;
      $new_h = $src_h;
  }else{
      $new_w = $src_w;
      $new_h = $src_w;
  }

the above methods will be slightly horizontally and vertically centered, but there will still be differences

but how can I find no relevant resources or practices
it is also possible that I am looking for a question
that no one has the answer?

charge
I opened an empty cloth
clipboard.png

clipboard.png


clipboard.png

clipboard.png

clipboard.png

clipboard.png

imagecopyresampled($plat300, $src, 0, 0, 0, 0, 300, 300, $src_w, $src_h);

clipboard.png

clipboard.png

Mar.17,2021

thanks for the invitation, why not consider reducing the user's complete image to 300 300 and placing it on the left side of the image you want to composite? If it is really as long as the picture in the middle of the 300 300 part, it is also very simple. Suppose that the length and width of the picture uploaded by the user are wmai h, respectively, and when you use the imagecopyresampled function to put the user's picture on the picture you want to synthesize, the coordinates of the original image are (wmur300) / 2, (hmur300) / 2, respectively, you can get the piece with 300mm 300 in the center of the picture uploaded by the user.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b37b6b-e606.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b37b6b-e606.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?