1
0
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:
Oliver Vogel
2014-05-24 18:56:47 +02:00
parent f63b2a4dd5
commit 6638929324
3 changed files with 21 additions and 1 deletions

View File

@@ -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);
}

View File

@@ -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');

View File

@@ -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');