diff --git a/src/Drivers/Abstract/AbstractImage.php b/src/Drivers/Abstract/AbstractImage.php index fbac55d9..a7be7afa 100644 --- a/src/Drivers/Abstract/AbstractImage.php +++ b/src/Drivers/Abstract/AbstractImage.php @@ -219,6 +219,11 @@ abstract class AbstractImage implements ImageInterface ); } + /** + * {@inheritdoc} + * + * @see ImageInterface::pickColors() + */ public function pickColors(int $x, int $y): CollectionInterface { $colors = new Collection(); diff --git a/src/Drivers/Gd/Image.php b/src/Drivers/Gd/Image.php index dbe8ea53..6b24619d 100644 --- a/src/Drivers/Gd/Image.php +++ b/src/Drivers/Gd/Image.php @@ -78,15 +78,11 @@ class Image extends AbstractImage implements ImageInterface, IteratorAggregate 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( - imagecolorat($frame->getCore(), $x, $y) - ); - } - - return null; + return $this->integerToColor( + imagecolorat($this->frame($frame_key)->getCore(), $x, $y) + ); } /** diff --git a/src/Drivers/Imagick/Image.php b/src/Drivers/Imagick/Image.php index f7226f46..a83d9a67 100644 --- a/src/Drivers/Imagick/Image.php +++ b/src/Drivers/Imagick/Image.php @@ -134,16 +134,17 @@ class Image extends AbstractImage implements ImageInterface, Iterator 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( - $frame->getCore()->getImagePixelColor($x, $y), - $this->getColorspace() - ); - } - - return null; + return $this->pixelToColor( + $this->frame($frame_key)->getCore()->getImagePixelColor($x, $y), + $this->getColorspace() + ); } public function getColorspace(): ColorspaceInterface diff --git a/src/Interfaces/ImageInterface.php b/src/Interfaces/ImageInterface.php index c179f168..56b36b08 100644 --- a/src/Interfaces/ImageInterface.php +++ b/src/Interfaces/ImageInterface.php @@ -137,7 +137,23 @@ interface ImageInterface extends Traversable, Countable */ 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; /**