mirror of
https://github.com/Intervention/image.git
synced 2025-08-19 12:11:26 +02:00
Remove remaining toRgb() calls
This commit is contained in:
@@ -76,11 +76,6 @@ class Color implements ColorInterface
|
||||
);
|
||||
}
|
||||
|
||||
public function toRgb(): self
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function convertTo(string|ColorspaceInterface $colorspace): ColorInterface
|
||||
{
|
||||
$colorspace = match (true) {
|
||||
|
@@ -3,6 +3,7 @@
|
||||
namespace Intervention\Image\Drivers\Gd\Traits;
|
||||
|
||||
use Intervention\Image\Colors\Rgb\Color;
|
||||
use Intervention\Image\Colors\Rgb\Colorspace;
|
||||
use Intervention\Image\Interfaces\ColorInterface;
|
||||
|
||||
trait CanHandleColors
|
||||
@@ -33,9 +34,9 @@ trait CanHandleColors
|
||||
* @param ColorInterface $color
|
||||
* @return int
|
||||
*/
|
||||
public function colorToInteger(ColorInterface $color): int
|
||||
public function colorToInteger(Color $color): int
|
||||
{
|
||||
$color = $color->toRgb();
|
||||
$color = $color->convertTo(Colorspace::class);
|
||||
|
||||
$r = $color->red()->value();
|
||||
$g = $color->green()->value();
|
||||
|
@@ -25,6 +25,7 @@ class BinaryImageDecoder extends AbstractDecoder implements DecoderInterface
|
||||
$imagick = new Imagick();
|
||||
$imagick->readImageBlob($input);
|
||||
$imagick = $imagick->coalesceImages();
|
||||
// $imagick->transformImageColorspace(Imagick::COLORSPACE_RGB);
|
||||
|
||||
$image = new Image($imagick);
|
||||
$image->setLoops($imagick->getImageIterations());
|
||||
|
@@ -2,16 +2,14 @@
|
||||
|
||||
namespace Intervention\Image\Interfaces;
|
||||
|
||||
use Intervention\Image\Colors\Rgb\Color;
|
||||
|
||||
interface ColorInterface
|
||||
{
|
||||
public function toRgb(): Color;
|
||||
public function toArray(): array;
|
||||
public function toString(): string;
|
||||
public function toHex(): string;
|
||||
public function __toString(): string;
|
||||
public function toString(): string;
|
||||
public function toArray(): array;
|
||||
public function toHex(): string;
|
||||
public function channels(): array;
|
||||
public function channel(string $classname): ColorChannelInterface;
|
||||
public function convertTo(string|ColorspaceInterface $colorspace): ColorInterface;
|
||||
public function isGreyscale(): bool;
|
||||
}
|
||||
|
@@ -73,10 +73,4 @@ class ColorTest extends TestCase
|
||||
$color = new Color(181, 55, 23);
|
||||
$this->assertEquals('rgb(181, 55, 23)', (string) $color);
|
||||
}
|
||||
|
||||
public function testToRgb(): void
|
||||
{
|
||||
$color = new Color(181, 55, 23);
|
||||
$this->assertInstanceOf(Color::class, $color->toRgb());
|
||||
}
|
||||
}
|
||||
|
@@ -96,21 +96,15 @@ class ImageTest extends TestCase
|
||||
{
|
||||
$color = $this->image->pickColor(0, 0);
|
||||
$this->assertInstanceOf(Color::class, $color);
|
||||
$this->assertEquals(255, $color->toRgb()->red()->value());
|
||||
$this->assertEquals(0, $color->toRgb()->green()->value());
|
||||
$this->assertEquals(0, $color->toRgb()->blue()->value());
|
||||
$this->assertEquals([255, 0, 0, 255], $color->toArray());
|
||||
|
||||
$color = $this->image->pickColor(0, 0, 1);
|
||||
$this->assertInstanceOf(Color::class, $color);
|
||||
$this->assertEquals(0, $color->toRgb()->red()->value());
|
||||
$this->assertEquals(255, $color->toRgb()->green()->value());
|
||||
$this->assertEquals(0, $color->toRgb()->blue()->value());
|
||||
$this->assertEquals([0, 255, 0, 255], $color->toArray());
|
||||
|
||||
$color = $this->image->pickColor(0, 0, 2);
|
||||
$this->assertInstanceOf(Color::class, $color);
|
||||
$this->assertEquals(0, $color->toRgb()->red()->value());
|
||||
$this->assertEquals(0, $color->toRgb()->green()->value());
|
||||
$this->assertEquals(255, $color->toRgb()->blue()->value());
|
||||
$this->assertEquals([0, 0, 255, 255], $color->toArray());
|
||||
|
||||
$color = $this->image->pickColor(0, 0, 3);
|
||||
$this->assertNull($color);
|
||||
@@ -121,17 +115,8 @@ class ImageTest extends TestCase
|
||||
$colors = $this->image->pickColors(0, 0);
|
||||
$this->assertInstanceOf(Collection::class, $colors);
|
||||
$this->assertCount(3, $colors);
|
||||
|
||||
$this->assertEquals(255, $colors->get(0)->toRgb()->red()->value());
|
||||
$this->assertEquals(0, $colors->get(0)->toRgb()->green()->value());
|
||||
$this->assertEquals(0, $colors->get(0)->toRgb()->blue()->value());
|
||||
|
||||
$this->assertEquals(0, $colors->get(1)->toRgb()->red()->value());
|
||||
$this->assertEquals(255, $colors->get(1)->toRgb()->green()->value());
|
||||
$this->assertEquals(0, $colors->get(1)->toRgb()->blue()->value());
|
||||
|
||||
$this->assertEquals(0, $colors->get(2)->toRgb()->red()->value());
|
||||
$this->assertEquals(0, $colors->get(2)->toRgb()->green()->value());
|
||||
$this->assertEquals(255, $colors->get(2)->toRgb()->blue()->value());
|
||||
$this->assertEquals([255, 0, 0, 255], $colors->get(0)->toArray());
|
||||
$this->assertEquals([0, 255, 0, 255], $colors->get(1)->toArray());
|
||||
$this->assertEquals([0, 0, 255, 255], $colors->get(2)->toArray());
|
||||
}
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@
|
||||
namespace Intervention\Image\Tests;
|
||||
|
||||
use Intervention\Image\Colors\Rgb\Color;
|
||||
use Intervention\Image\Colors\Rgb\Colorspace;
|
||||
use Intervention\Image\Interfaces\ColorInterface;
|
||||
use Mockery\Adapter\Phpunit\MockeryTestCase;
|
||||
|
||||
@@ -26,6 +27,6 @@ abstract class TestCase extends MockeryTestCase
|
||||
protected function assertTransparency(ColorInterface $color)
|
||||
{
|
||||
$this->assertInstanceOf(Color::class, $color);
|
||||
$this->assertEquals(0, $color->toRgb()->alpha()->value());
|
||||
$this->assertEquals(0, $color->convertTo(Colorspace::class)->alpha()->value());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user