Файл: vendor/intervention/image/src/Modifiers/CropModifier.php
Строк: 90
<?php
declare(strict_types=1);
namespace InterventionImageModifiers;
use InterventionImageAlignment;
use InterventionImageDriversSpecializableModifier;
use InterventionImageExceptionsInvalidArgumentException;
use InterventionImageExceptionsStateException;
use InterventionImageInterfacesColorInterface;
use InterventionImageInterfacesImageInterface;
use InterventionImageInterfacesSizeInterface;
use InterventionImageSize;
class CropModifier extends SpecializableModifier
{
/**
* Create new modifier object.
*/
public function __construct(
public int $width,
public int $height,
public int $x = 0,
public int $y = 0,
public null|string|ColorInterface $background = null,
public string|Alignment $alignment = Alignment::TOP_LEFT,
) {
//
}
/**
* @throws InvalidArgumentException
*/
protected function crop(ImageInterface $image): SizeInterface
{
$crop = new Size($this->width, $this->height);
$crop->movePivot($this->alignment);
return $crop->alignPivotTo(
$image->size(),
$this->alignment,
);
}
/**
* Return color to fill the newly created areas after resizing
*
* @throws StateException
*/
protected function backgroundColor(): ColorInterface
{
return $this->driver()->decodeColor(
$this->background ?? $this->driver()->config()->backgroundColor,
);
}
}