1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-12 08:54:03 +02:00

Merge branch 'next' into next-method-renaming

This commit is contained in:
Oliver Vogel
2023-10-26 16:14:55 +02:00
4 changed files with 36 additions and 18 deletions

View File

@@ -219,6 +219,11 @@ abstract class AbstractImage implements ImageInterface
); );
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::pickColors()
*/
public function pickColors(int $x, int $y): CollectionInterface public function pickColors(int $x, int $y): CollectionInterface
{ {
$colors = new Collection(); $colors = new Collection();

View File

@@ -78,17 +78,13 @@ class Image extends AbstractImage implements ImageInterface, IteratorAggregate
return imagesy($this->frame()->getCore()); return imagesy($this->frame()->getCore());
} }
public function pickColor(int $x, int $y, int $frame_key = 0): ?ColorInterface public function pickColor(int $x, int $y, int $frame_key = 0): ColorInterface
{ {
if ($frame = $this->frame($frame_key)) {
return $this->integerToColor( return $this->integerToColor(
imagecolorat($frame->getCore(), $x, $y) imagecolorat($this->frame($frame_key)->getCore(), $x, $y)
); );
} }
return null;
}
/** /**
* {@inheritdoc} * {@inheritdoc}
* *

View File

@@ -134,18 +134,19 @@ class Image extends AbstractImage implements ImageInterface, Iterator
return $this->frame()->getCore()->getImageHeight(); return $this->frame()->getCore()->getImageHeight();
} }
public function pickColor(int $x, int $y, int $frame_key = 0): ?ColorInterface /**
* {@inheritdoc}
*
* @see ImageInterface::pickColor()
*/
public function pickColor(int $x, int $y, int $frame_key = 0): ColorInterface
{ {
if ($frame = $this->frame($frame_key)) {
return $this->pixelToColor( return $this->pixelToColor(
$frame->getCore()->getImagePixelColor($x, $y), $this->frame($frame_key)->getCore()->getImagePixelColor($x, $y),
$this->getColorspace() $this->getColorspace()
); );
} }
return null;
}
public function getColorspace(): ColorspaceInterface public function getColorspace(): ColorspaceInterface
{ {
return match ($this->imagick->getImageColorspace()) { return match ($this->imagick->getImageColorspace()) {

View File

@@ -137,7 +137,23 @@ interface ImageInterface extends Traversable, Countable
*/ */
public function toPng(): EncodedImage; public function toPng(): EncodedImage;
public function pickColor(int $x, int $y, int $frame_key = 0): ?ColorInterface; /**
* Return color of pixel at given position on given frame position
*
* @param int $x
* @param int $y
* @param int $frame_key
* @return ColorInterface
*/
public function pickColor(int $x, int $y, int $frame_key = 0): ColorInterface;
/**
* Return all colors of pixel at given position for all frames of image
*
* @param int $x
* @param int $y
* @return ColorInterface
*/
public function pickColors(int $x, int $y): CollectionInterface; public function pickColors(int $x, int $y): CollectionInterface;
/** /**