Crop
Cropping is the removal of unwanted outer areas from an image. The crop
parameter sets the form of how the image is cropped and sized.
Aliases
c
Types
crop
: cropping the imagescale
,sc
: resizing the image without keeping the aspect ratiofit
: resizing the image with keeping the aspect ratiolfit
: same as fit, but does not allow you to resize the image beyond its original sizepadding
,pad
: resizes while keeping the aspect ratio. Does not crop from the picture and the new area of the image is filled up by the parameterbackground
; the parameterswidth
andheight
are compulsorylpad
,lp
: the same aspadding
, but does not allow you to resize the image beyond the initial sizefill
,fl
(default): resizes the image to as large as possible while keeping the aspect ratio, then crops the image as specified in the width and height according to the value ingravity
; the parameterswidth
andheight
are compulsorylfill
,lfl
: likefill
, without allowing you to resize the image beyond its initial sizetrim
,trim:{fuzzy}
: automatically crops the image according to the frame’s continuity; the default value is set to30
Limitations
- This transformation does not have any known limitations.
Dependencies
Examples
Crop the image to 200x200px.
wh:200_c:crop
use shardimage\shardimagephp\factories\Transformation;
$transformations = (new Transformation())->size(200)->crop();
Crop the image to 100x100px, while keeping the aspect ratio.
wh:100
or
wh:100_c:fill
use shardimage\shardimagephp\factories\Transformation;
$transformations = (new Transformation())->size(100)->fill();
Cropping the image in multiple steps.
wh:500/w:100_c:crop
use shardimage\shardimagephp\factories\Transformation;
$transformations = (new Transformation())->size(500)->group()->width(100)->crop();
Cropping the image using pad.
wh:100_c:pad_bg:red
use shardimage\shardimagephp\factories\Transformation;
$transformations = (new Transformation())->size(100)->pad()->background('red');
Cropping the image using scale.
w:100_h:150_c:sc
use shardimage\shardimagephp\factories\Transformation;
$transformations = (new Transformation())->width(100)->height(150)->scale();