Файл: vendor/intervention/image/src/Modifiers/ReduceColorsModifier.php
Строк: 65
<?php
declare(strict_types=1);
namespace InterventionImageModifiers;
use InterventionImageDriversSpecializableModifier;
use InterventionImageExceptionsInvalidArgumentException;
use InterventionImageExceptionsStateException;
use InterventionImageInterfacesColorInterface;
use InterventionImageInterfacesImageInterface;
class ReduceColorsModifier extends SpecializableModifier
{
/**
* Create new modifier object.
*
* @throws InvalidArgumentException
*/
public function __construct(
public int $limit,
public null|string|ColorInterface $background = null,
) {
if ($this->limit < 1) {
throw new InvalidArgumentException('Invalid color limit. Only use int<1, max>');
}
}
/**
* Return color in colorspace of image to fill transparent areas.
*
* @throws StateException
*/
protected function backgroundColor(ImageInterface $image): ColorInterface
{
return $this->driver()->decodeColor(
$this->background ?? $this->driver()->config()->backgroundColor,
)->toColorspace($image->colorspace());
}
}