Type to search...

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 image
  • scale, sc: resizing the image without keeping the aspect ratio
  • fit: resizing the image with keeping the aspect ratio
  • lfit: same as fit, but does not allow you to resize the image beyond its original size
  • padding, 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 parameter background; the parameters width and height are compulsory
  • lapd, lp: the same as padding, but does not allow you to resize the image beyond the initial size
  • fill, 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 in gravity; the parameters width and height are compulsory
  • lfill, lfl: like fill, without allowing you to resize the image beyond its initial size
  • trim, trim:{fuzzy}: automatically crops the image according to the frame’s continuity; the default value is set to 30

Limitations

  • This transformation does not have any known limitations.

Dependencies

Examples

Crop the image to 200x200px.

wh:200_c:crop

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_c:crop

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:100_c:crop

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:crop

wh:100_c:pad_bg:red
use shardimage\shardimagephp\factories\Transformation;
$transformations = (new Transformation())->size(100)->pad()->background('red');

Cropping the image using scale.

wh:100_c:crop

w:100_h:150_c:sc
use shardimage\shardimagephp\factories\Transformation;
$transformations = (new Transformation())->width(100)->height(150)->scale();
Table of contents