PHP:两个图像(在调整比例后)成形为一个图像

I want to resize my two images to fit best and keep ratio and put them into shape (two circles). I am wondering about easier method to resolve my problem. I want to get this result shown on image below:

enter image description here

  1. Load src image 1 and src image 2: I got this
  2. to square with aspect ratio: I use Eventviva/Php-image-resize
  3. to circle: I found some code for this on stackoverflow, but still finding and trying to get the best
  4. to shape: I don't know how to do it (my idea written below)

My idea: I was thinking about use imagecopymerge in this way: open imagecircle1, then add white outline border on imagecircle2, then set imagecircle2 with border to right bottom corner and save but first of all - it wont be transpared because of white border, moreover I am sure that easier way exists but I cant find it.

Any ideas how to get result shown on image with easier way? Or if my idea is correct, can you help me a bit with shape?

Lukasz, a good place to start is to use image transformations service via URL where you can mesh your images together in various ways, applying filters, backgrounds, reshape, etc.

HTH.