mirror of
https://github.com/Intervention/image.git
synced 2025-08-01 11:30:16 +02:00
allow limitColors to be called with null
This commit is contained in:
@@ -39,7 +39,7 @@ class LimitColorsCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
// copy original image
|
||||
imagecopy($resource, $image->getCore(), 0, 0, 0, 0, $size->width, $size->height);
|
||||
|
||||
if ($count <= 256) {
|
||||
if (is_numeric($count) && $count <= 256) {
|
||||
// decrease colors
|
||||
imagetruecolortopalette($resource, true, $count);
|
||||
}
|
||||
|
@@ -1076,6 +1076,16 @@ class GdSystemTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertColorAtPosition('#e40214', $img, 16, 21);
|
||||
}
|
||||
|
||||
public function testLimitColorsNullWithMatte()
|
||||
{
|
||||
$img = $this->manager()->make('tests/images/tile.png');
|
||||
$img->limitColors(null, '#ff00ff');
|
||||
$this->assertColorAtPosition('#b4e000', $img, 0, 0);
|
||||
$this->assertColorAtPosition('#445160', $img, 8, 8);
|
||||
$this->assertColorAtPosition('#ff00ff', $img, 0, 8);
|
||||
$this->assertColorAtPosition('#ff00ff', $img, 15, 0);
|
||||
}
|
||||
|
||||
public function testPickColorFromTrueColor()
|
||||
{
|
||||
$img = $this->manager()->make('tests/images/star.png');
|
||||
|
@@ -1049,6 +1049,16 @@ class ImagickSystemTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertColorAtPosition('#e70012', $img, 16, 21);
|
||||
}
|
||||
|
||||
public function testLimitColorsNullWithMatte()
|
||||
{
|
||||
$img = $this->manager()->make('tests/images/tile.png');
|
||||
$img->limitColors(null, '#ff00ff');
|
||||
$this->assertColorAtPosition('#b4e000', $img, 0, 0);
|
||||
$this->assertColorAtPosition('#445160', $img, 8, 8);
|
||||
$this->assertColorAtPosition('#ff00ff', $img, 0, 8);
|
||||
$this->assertColorAtPosition('#ff00ff', $img, 15, 0);
|
||||
}
|
||||
|
||||
public function testPickColorFromTrueColor()
|
||||
{
|
||||
$img = $this->manager()->make('tests/images/star.png');
|
||||
|
Reference in New Issue
Block a user