Gravity
Gravity provides the part of the image we want to focus on.
gravity
You can specify multiple values; the most successful (executable) version is going to be the valid one (e.g.: if there is no face on the image, it will skip to the next one, if there is a next one specified).
- with layers (over, under, text) it provides the anchor point of the paste. In this case, the
x
,y
values should be interpreted s starting from the anchor points, and the positive values are always point towards the center.
Parameters
faces
*: including all faces;crop
will be overwritten, sowidth
andheight
will be disregardedface
*: the first detected face;crop
will be overwritten,width
andheight
will be disregardedface:{N}
*: the Nth detected face;crop
will be overwritten,width
andheight
will be disregardedeyes
*: including all eyes;crop
will be overwritten,width
andheight
will be disregardedtop-left
,tl
: upper left cornertop-right
,tr
: upper right cornerbottom-left
,bl
: lower left cornerbottom-right
,br
: lower right cornerleft
,l
: center of left sideright
,r
: center of right sidebottom
,b
: center of bottomtop
: center of upper partcenter
: center (default)xy-center
: center for X,Y points; the specification ofx
andy
points are mandatory
*: beta version
Limitations
- This transformation does not have any limitations.
Dependencies
Examples
Find the face and focus on it
g:face/wh:100
use shardimage\shardimagephp\factories\Transformation;
$transformations = (new Transformation())->gFace()->group()->size(100);
Focus on the left side
wh:300/g:left_w:120
use shardimage\shardimagephp\factories\Transformation;
$transformations = (new Transformation())->size(300)->group()->gLeft()->width(120);
Focus on the bottom right side
w:300/g:br_wh:100
use shardimage\shardimagephp\factories\Transformation;
$transformations = (new Transformation())->width(300)->group()->gBottomRight()->size(100);
Focus on the given X,Y points
w:500/c:crop_g:xy-center_x:140_y:230_w:120_h:60
use shardimage\shardimagephp\factories\Transformation;
$transformations = (new Transformation())->width(500)->group()->crop()->gXYCenter()->x(140)->y(230)->width(120)->height(60);
Focus on face and the top right side
w:200/g:face,tr_wh:100
use shardimage\shardimagephp\factories\Transformation;
$transformations = (new Transformation())->width(200)->group()->gFace()->gTopRight()->size(100);
Find the face and focus on it; the height and weight is set to 100 px
g:face:3/wh:100
use shardimage\shardimagephp\factories\Transformation;
$transformations = (new Transformation())->gFace(3)->group()->size(100);