Intervention/image · error · InvalidArgumentException
Invalid color limit. Must be int<1, max>
Error message
Invalid color limit. Must be int<1, max>
What it means
Error "Invalid color limit. Must be int<1, max>" thrown in Intervention/image.
Source
Thrown at src/Modifiers/ReduceColorsModifier.php:25
use Intervention\Image\Drivers\SpecializableModifier;
use Intervention\Image\Exceptions\InvalidArgumentException;
use Intervention\Image\Exceptions\StateException;
use Intervention\Image\Interfaces\ColorInterface;
use Intervention\Image\Interfaces\ImageInterface;
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. Must be int<1, max>');
}
}
/**
* Return the color in the image's colorspace 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());
}
}
View on GitHub (pinned to 5598b9e397)
Solutions
- Pass a color limit of at least 1 to reduceColors()
- Clamp computed limits: max(1, (int) $limit)
- Note practical upper bounds depend on the driver; keep limits within a sane range (1-255)
When it happens
Trigger: Thrown at src/Modifiers/ReduceColorsModifier.php:25 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Intervention/image@5598b9e397 (2026-08-23).
Data as JSON: /api/errors/4bcc2d08be10fc53.
Report an issue: GitHub.