I was referring example of Imagick::distortImage
Now look at Example 1 which generates following image
I got confused while looking at below part of code.
/* Control points for the distortion */
$controlPoints = array( 10, 10,
10, 5,
10, $im->getImageHeight() - 20,
10, $im->getImageHeight() - 5,
$im->getImageWidth() - 10, 10,
$im->getImageWidth() - 10, 20,
$im->getImageWidth() - 10, $im->getImageHeight() - 10,
$im->getImageWidth() - 10, $im->getImageHeight() - 30);
Now can anybody tell me what this 16 points exactly means ?
The control point arguments are helpfully organised into this layout:
x1 , y1 ,
x1' , y1' ,
x2 , y2 ,
x2' , y2' ,
x3 , y3 ,
x3' , y3' ,
x4 , y4 ,
x4' , y4'
For each set of coordinates, x_
and y_
are the source points, and x_'
and y_'
are the targets.
So it's taking the top-left corner and moving it up a bit, the bottom-left is being moved down, the top-right is being moved down and the bottom-right is being moved up, producing the perspective result.