mirror of
https://github.com/Intervention/image.git
synced 2025-08-18 03:31:19 +02:00
Rename method
- ImageInterface::getColorspace to ImageInterface::colorspace
This commit is contained in:
@@ -90,7 +90,7 @@ class Image extends AbstractImage implements ImageInterface, IteratorAggregate
|
||||
*
|
||||
* @see ImageInterface::getColorspace()
|
||||
*/
|
||||
public function getColorspace(): ColorspaceInterface
|
||||
public function colorspace(): ColorspaceInterface
|
||||
{
|
||||
return new RgbColorspace();
|
||||
}
|
||||
|
@@ -143,11 +143,11 @@ class Image extends AbstractImage implements ImageInterface, Iterator
|
||||
{
|
||||
return $this->pixelToColor(
|
||||
$this->frame($frame_key)->getCore()->getImagePixelColor($x, $y),
|
||||
$this->getColorspace()
|
||||
$this->colorspace()
|
||||
);
|
||||
}
|
||||
|
||||
public function getColorspace(): ColorspaceInterface
|
||||
public function colorspace(): ColorspaceInterface
|
||||
{
|
||||
return match ($this->imagick->getImageColorspace()) {
|
||||
Imagick::COLORSPACE_CMYK => new CmykColorspace(),
|
||||
|
@@ -14,7 +14,7 @@ class DrawEllipseModifier extends AbstractDrawModifier implements ModifierInterf
|
||||
|
||||
public function apply(ImageInterface $image): ImageInterface
|
||||
{
|
||||
$colorspace = $image->getColorspace();
|
||||
$colorspace = $image->colorspace();
|
||||
$background_color = $this->colorToPixel($this->getBackgroundColor(), $colorspace);
|
||||
$border_color = $this->colorToPixel($this->getBorderColor(), $colorspace);
|
||||
|
||||
|
@@ -17,7 +17,7 @@ class DrawLineModifier extends AbstractDrawModifier implements ModifierInterface
|
||||
$drawing = new ImagickDraw();
|
||||
$drawing->setStrokeWidth($this->line()->getWidth());
|
||||
$drawing->setStrokeColor(
|
||||
$this->colorToPixel($this->getBackgroundColor(), $image->getColorspace())
|
||||
$this->colorToPixel($this->getBackgroundColor(), $image->colorspace())
|
||||
);
|
||||
|
||||
$drawing->line(
|
||||
|
@@ -30,7 +30,7 @@ class DrawPixelModifier implements ModifierInterface
|
||||
);
|
||||
|
||||
$pixel = new ImagickDraw();
|
||||
$pixel->setFillColor($this->colorToPixel($color, $image->getColorspace()));
|
||||
$pixel->setFillColor($this->colorToPixel($color, $image->colorspace()));
|
||||
$pixel->point($this->position->getX(), $this->position->getY());
|
||||
|
||||
return $image->mapFrames(function ($frame) use ($pixel) {
|
||||
|
@@ -22,7 +22,7 @@ class DrawPolygonModifier extends AbstractDrawModifier implements ModifierInterf
|
||||
public function apply(ImageInterface $image): ImageInterface
|
||||
{
|
||||
$drawing = new ImagickDraw();
|
||||
$colorspace = $image->getColorspace();
|
||||
$colorspace = $image->colorspace();
|
||||
$background_color = $this->colorToPixel($this->getBackgroundColor(), $colorspace);
|
||||
$border_color = $this->colorToPixel($this->getBorderColor(), $colorspace);
|
||||
|
||||
|
@@ -15,7 +15,7 @@ class DrawRectangleModifier extends AbstractDrawModifier implements ModifierInte
|
||||
public function apply(ImageInterface $image): ImageInterface
|
||||
{
|
||||
$drawing = new ImagickDraw();
|
||||
$colorspace = $image->getColorspace();
|
||||
$colorspace = $image->colorspace();
|
||||
$background_color = $this->colorToPixel($this->getBackgroundColor(), $colorspace);
|
||||
$border_color = $this->colorToPixel($this->getBorderColor(), $colorspace);
|
||||
|
||||
|
@@ -25,7 +25,7 @@ class FillModifier implements ModifierInterface
|
||||
|
||||
public function apply(ImageInterface $image): ImageInterface
|
||||
{
|
||||
$pixel = $this->colorToPixel($this->color, $image->getColorspace());
|
||||
$pixel = $this->colorToPixel($this->color, $image->colorspace());
|
||||
|
||||
foreach ($image as $frame) {
|
||||
if ($this->hasPosition()) {
|
||||
|
@@ -15,7 +15,7 @@ class RotateModifier extends AbstractRotateModifier implements ModifierInterface
|
||||
{
|
||||
foreach ($image as $frame) {
|
||||
$frame->getCore()->rotateImage(
|
||||
$this->colorToPixel($this->backgroundColor(), $image->getColorspace()),
|
||||
$this->colorToPixel($this->backgroundColor(), $image->colorspace()),
|
||||
$this->rotationAngle()
|
||||
);
|
||||
}
|
||||
|
@@ -16,7 +16,7 @@ class TextWriter extends AbstractTextWriter
|
||||
foreach ($image as $frame) {
|
||||
foreach ($lines as $line) {
|
||||
$frame->getCore()->annotateImage(
|
||||
$font->toImagickDraw($image->getColorspace()),
|
||||
$font->toImagickDraw($image->colorspace()),
|
||||
$line->getPosition()->getX(),
|
||||
$line->getPosition()->getY(),
|
||||
$font->getAngle(),
|
||||
|
@@ -161,7 +161,7 @@ interface ImageInterface extends Traversable, Countable
|
||||
*
|
||||
* @return ColorspaceInterface
|
||||
*/
|
||||
public function getColorspace(): ColorspaceInterface;
|
||||
public function colorspace(): ColorspaceInterface;
|
||||
|
||||
/**
|
||||
* Transform image to given colorspace
|
||||
|
@@ -126,22 +126,22 @@ class ImageTest extends TestCase
|
||||
|
||||
public function testGetColorspace(): void
|
||||
{
|
||||
$this->assertInstanceOf(RgbColorspace::class, $this->image->getColorspace());
|
||||
$this->assertInstanceOf(RgbColorspace::class, $this->image->colorspace());
|
||||
}
|
||||
|
||||
public function testSetColorspace(): void
|
||||
{
|
||||
$result = $this->image->setColorspace('rgb');
|
||||
$this->assertInstanceOf(Image::class, $result);
|
||||
$this->assertInstanceOf(RgbColorspace::class, $result->getColorspace());
|
||||
$this->assertInstanceOf(RgbColorspace::class, $result->colorspace());
|
||||
|
||||
$result = $this->image->setColorspace(RgbColorspace::class);
|
||||
$this->assertInstanceOf(Image::class, $result);
|
||||
$this->assertInstanceOf(RgbColorspace::class, $result->getColorspace());
|
||||
$this->assertInstanceOf(RgbColorspace::class, $result->colorspace());
|
||||
|
||||
$result = $this->image->setColorspace(new RgbColorspace());
|
||||
$this->assertInstanceOf(Image::class, $result);
|
||||
$this->assertInstanceOf(RgbColorspace::class, $result->getColorspace());
|
||||
$this->assertInstanceOf(RgbColorspace::class, $result->colorspace());
|
||||
|
||||
$this->expectException(NotSupportedException::class);
|
||||
$this->image->setColorspace('cmyk');
|
||||
|
@@ -15,7 +15,7 @@ class BinaryImageDecoderTest extends TestCase
|
||||
$decoder = new BinaryImageDecoder();
|
||||
$image = $decoder->decode(file_get_contents($this->getTestImagePath('tile.png')));
|
||||
$this->assertInstanceOf(Image::class, $image);
|
||||
$this->assertInstanceOf(RgbColorspace::class, $image->getColorspace());
|
||||
$this->assertInstanceOf(RgbColorspace::class, $image->colorspace());
|
||||
$this->assertEquals(16, $image->width());
|
||||
$this->assertEquals(16, $image->height());
|
||||
$this->assertCount(1, $image);
|
||||
@@ -57,6 +57,6 @@ class BinaryImageDecoderTest extends TestCase
|
||||
$decoder = new BinaryImageDecoder();
|
||||
$image = $decoder->decode(file_get_contents($this->getTestImagePath('cmyk.jpg')));
|
||||
$this->assertInstanceOf(Image::class, $image);
|
||||
$this->assertInstanceOf(CmykColorspace::class, $image->getColorspace());
|
||||
$this->assertInstanceOf(CmykColorspace::class, $image->colorspace());
|
||||
}
|
||||
}
|
||||
|
@@ -99,39 +99,39 @@ class ImageTest extends TestCase
|
||||
$imagick = new Imagick();
|
||||
$imagick->readImageBlob($this->getTestImageData('test.jpg'));
|
||||
$image = new Image($imagick);
|
||||
$this->assertInstanceOf(RgbColorspace::class, $image->getColorspace());
|
||||
$this->assertInstanceOf(RgbColorspace::class, $image->colorspace());
|
||||
|
||||
$imagick = new Imagick();
|
||||
$imagick->readImageBlob($this->getTestImageData('cmyk.jpg'));
|
||||
$image = new Image($imagick);
|
||||
$this->assertInstanceOf(CmykColorspace::class, $image->getColorspace());
|
||||
$this->assertInstanceOf(CmykColorspace::class, $image->colorspace());
|
||||
}
|
||||
|
||||
public function testSetColorspace(): void
|
||||
{
|
||||
$result = $this->image->setColorspace('rgb');
|
||||
$this->assertInstanceOf(Image::class, $result);
|
||||
$this->assertInstanceOf(RgbColorspace::class, $result->getColorspace());
|
||||
$this->assertInstanceOf(RgbColorspace::class, $result->colorspace());
|
||||
|
||||
$result = $this->image->setColorspace(RgbColorspace::class);
|
||||
$this->assertInstanceOf(Image::class, $result);
|
||||
$this->assertInstanceOf(RgbColorspace::class, $result->getColorspace());
|
||||
$this->assertInstanceOf(RgbColorspace::class, $result->colorspace());
|
||||
|
||||
$result = $this->image->setColorspace(new RgbColorspace());
|
||||
$this->assertInstanceOf(Image::class, $result);
|
||||
$this->assertInstanceOf(RgbColorspace::class, $result->getColorspace());
|
||||
$this->assertInstanceOf(RgbColorspace::class, $result->colorspace());
|
||||
|
||||
$result = $this->image->setColorspace('cmyk');
|
||||
$this->assertInstanceOf(Image::class, $result);
|
||||
$this->assertInstanceOf(CmykColorspace::class, $result->getColorspace());
|
||||
$this->assertInstanceOf(CmykColorspace::class, $result->colorspace());
|
||||
|
||||
$result = $this->image->setColorspace(CmykColorspace::class);
|
||||
$this->assertInstanceOf(Image::class, $result);
|
||||
$this->assertInstanceOf(CmykColorspace::class, $result->getColorspace());
|
||||
$this->assertInstanceOf(CmykColorspace::class, $result->colorspace());
|
||||
|
||||
$result = $this->image->setColorspace(new CmykColorspace());
|
||||
$this->assertInstanceOf(Image::class, $result);
|
||||
$this->assertInstanceOf(CmykColorspace::class, $result->getColorspace());
|
||||
$this->assertInstanceOf(CmykColorspace::class, $result->colorspace());
|
||||
}
|
||||
|
||||
public function testSetGetProfile(): void
|
||||
|
Reference in New Issue
Block a user