diff --git a/src/Intervention/Image/Gd/Commands/LimitColorsCommand.php b/src/Intervention/Image/Gd/Commands/LimitColorsCommand.php index dea31b50..a2889bec 100644 --- a/src/Intervention/Image/Gd/Commands/LimitColorsCommand.php +++ b/src/Intervention/Image/Gd/Commands/LimitColorsCommand.php @@ -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); } diff --git a/tests/GdSystemTest.php b/tests/GdSystemTest.php index 2499a8ee..8ec310f8 100644 --- a/tests/GdSystemTest.php +++ b/tests/GdSystemTest.php @@ -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'); diff --git a/tests/ImagickSystemTest.php b/tests/ImagickSystemTest.php index 8accab48..0ec1db41 100644 --- a/tests/ImagickSystemTest.php +++ b/tests/ImagickSystemTest.php @@ -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');