There is a pattern in PNG enter image description here

And there is a screenshot

enter image description here

PHP tools need:

a) Crop (resize?) the screenshot to fit the screen of the template (the screen is cut, it is transparent).

b) Give perspective to the screenshot.

c) Insert a screenshot into the transparent area of ​​the template.

What should I use - GD, Imagick? And how to insert a screenshot - by coordinates or mask of the template screen?

    1 answer 1

    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.