What I am trying to achieve is exactly the person in this question is trying. But in my case I want to code it as a PHP script.
I have seen some code to do it like this:
$controlPoints = array(
10, 10,
10, 5,
10, $screenshot->getImageHeight() - 20,
10, $screenshot->getImageHeight() - 5,
$screenshot->getImageWidth() - 10, 10,
$screenshot->getImageWidth() - 10, 20,
$screenshot->getImageWidth() - 10, $screenshot->getImageHeight() - 10,
$screenshot->getImageWidth() - 10, $screenshot->getImageHeight() - 30);
$screenshot->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, true);
But unfortunately I don't understand the maths behind the control points.
I think if I only had to input the 4 coordinates of the Image where I want to "stretch" the image it would be exactly what I need, but I'm not sure how to do it.