Type to search...

Perspective distortion

Creates perspective distortion on the images.


Perspective distortion is determined by the relative distances at which the image is captured and viewed, and is due to the angle of view of the image (as captured) being either wider or narrower than the angle of view at which the image is viewed, hence the apparent relative distances differing from what is expected.


  • in the case of 8 parameters (4 points): e:perspective:<D1.x>,<D1.y>,<D2.x>,<D2.y>,<D3.x>,<D3.y>,<D4.x>,<D4.y>
    • x1, y1: D1(x, y) (destination)
    • x2, y2: D2(x, y)
    • x3, y3: D3(x, y)
    • x4, y4: D4(y, y)

4 points perspective distortion effect

  • in the case of 16 parameters (8 points): e:perspective:<S1.x>,<S1.y>,<D1.x>,<D1.y>,<S2.x>,<S2.y>,<D2.x>,<D2.y>,<S3.x>,<S3.y>,<D3.x>,<D3.y>,<S4.x>,<S4.y><D4.x>,<D4.y>
    • x1, y1: S1(x, y) (source)
    • x2, y2: D1(x, y) (destination)
    • x3, y3: S2(x, y)
    • x4, y4: D2(x, y)
    • x5, y5: S3(x, y)
    • x6, y6: D3(x, y)
    • x7, y7: S4(x, y)
    • x8, y8: D4(x, y)

8 points perspective distortion effect


  • Applicable only to images smaller than 25 mega pixels.


  • This transformation does not have any dependencies.


See the following examples about the possible ways of usage.

Simple perspective shift

use shardimage\shardimagephp\factories\Transformation;
$transformations = (new Transformation())->width(300)->perspective(30,30,50,150,290,190,270,20)->background('white');

Advanced perspective shift, image into image

use shardimage\shardimagephp\factories\Transformation;
$transformations = (new Transformation())->gTopLeft()->width(400)->overlay('steve')->group()->crop()->gTopLeft()->width(150)->x(50)->group()->perspective(236,282,343,598,519,542,409,236)->end()->width(250);
Table of contents