I think it's worth using ImageMagick. He can distort in perspective, at four points - which is what you need. And here are some examples of distortions in php - you will need Bilinear:
//Example 5 - Bilinear $imagick = new \Imagick(realpath($this->control->getImagePath())); $points = array( 0, 0, 25, 25, # top left 176, 0, 126, 0, # top right 0, 135, 0, 105, # bottom right 176, 135, 176, 135 # bottum left ); $imagick->setImageBackgroundColor("#fad888"); $imagick->setImageVirtualPixelMethod(\Imagick::VIRTUALPIXELMETHOD_BACKGROUND); $imagick->distortImage(\Imagick::DISTORTION_BILINEAR, $points, true); header("Content-Type: image/jpeg"); echo $imagick;
It will take 4 points from the original image - just the corners of the screenshot, and 4 points that they should hit after distortion - the borders of the screen area in the PNG.
Your screen is not exactly proportional: it is square, and the screen of the iPad mini has a 4: 3 screen (1024: 768). If you enter the width, the bottom will be an empty space. If the height, the edge will be out of sight. Just enter - stretch in height.