Resize a photo based on two points and its distance

Is it difficult to do it?

Assume the frame showing the photo to be 600X600 pixels
When the user uploads a photo:
1: he enter a value D (for example, D=7)
2: He then point out two points (pt.A & pt.B)
Assume the bottom left corner to be (0,0)
3:The program then resize and rotate the photo such that,
y-coordinate for both pt.A and pt.B to be 400 pixel
x-coordinate for pt.A=300-8D=244 pixel
x-coordinate for pt.B=300+8D=356 pixel
4: The part outside the frame will be cut, and the image size becomes 600x600 pixels
5: Save the photo

Is it difficult to do so?

Thank you

thank you, this is part of the custom modification of a php website. I have no idea whether it is difficult to do so.