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