CropObjects
Crops the image to the objects detected by imgproxy’s object detection.
imgproxy: crop_objects (alias c_obj) · Availability: imgproxy Pro only
use SomehowDigital\ImgProxy\Url;use SomehowDigital\ImgProxy\Option\CropObjects;
$url = Url::create() ->source('https://example.com/image.jpg') ->options(new CropObjects(1.2, 'face'));
$url->build();// _/c_obj:1.2:face/plain/https%3A%2F%2Fexample.com%2Fimage.jpgThe option appears in the URL as c_obj:1.2:face.
Parameters
Section titled “Parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
$scale |
float |
required | Scale factor of the crop area. 1.2 adds 20% around the objects. |
$classes |
string ... |
— | Object classes to crop to. All detected objects when omitted. |
A dash means the argument can be left out. Trailing arguments that are left out or null are dropped from the URL, while a null before a given argument leaves an empty slot, so the following arguments keep their position.
- Takes precedence over
Crop. The image is not cropped when nothing is detected. - Introduced in imgproxy 4.0.