Reference

$file->crop()

Crops the image by the given width and height

$file->crop(int $width, int $height = null, string|array $options = null): Kirby\Cms\File

Parameters

Name Type Default Description
$width int
$height int null
$options string|array null

Return type

Kirby\Cms\File

Example

if($image = $page->image()):
    // crop into a square of 300 x 300
    echo $image->crop(300);

    // crop by height as well
    echo $image->crop(300, 200);

    // adjust the quality
    echo $image->crop(300, 200, 70);
endif;

Source code

kirby/src/Cms/File.php#L256