diff --git a/src/Drivers/Abstract/AbstractImage.php b/src/Drivers/Abstract/AbstractImage.php index a7be7afa..a0d713f8 100644 --- a/src/Drivers/Abstract/AbstractImage.php +++ b/src/Drivers/Abstract/AbstractImage.php @@ -29,7 +29,7 @@ abstract class AbstractImage implements ImageInterface protected ColorspaceInterface $colorspace; protected Collection $exif; - public function eachFrame(callable $callback): ImageInterface + public function mapFrames(callable $callback): ImageInterface { foreach ($this as $frame) { $callback($frame); diff --git a/src/Drivers/Gd/Modifiers/DrawEllipseModifier.php b/src/Drivers/Gd/Modifiers/DrawEllipseModifier.php index ed99cb3e..d31ff7d4 100644 --- a/src/Drivers/Gd/Modifiers/DrawEllipseModifier.php +++ b/src/Drivers/Gd/Modifiers/DrawEllipseModifier.php @@ -13,7 +13,7 @@ class DrawEllipseModifier extends AbstractDrawModifier implements ModifierInterf public function apply(ImageInterface $image): ImageInterface { - return $image->eachFrame(function ($frame) { + return $image->mapFrames(function ($frame) { if ($this->ellipse()->hasBorder()) { // slightly smaller ellipse to keep 1px bordered edges clean if ($this->ellipse()->hasBackgroundColor()) { diff --git a/src/Drivers/Gd/Modifiers/DrawLineModifier.php b/src/Drivers/Gd/Modifiers/DrawLineModifier.php index 9cfafb58..9ef6ffa0 100644 --- a/src/Drivers/Gd/Modifiers/DrawLineModifier.php +++ b/src/Drivers/Gd/Modifiers/DrawLineModifier.php @@ -13,7 +13,7 @@ class DrawLineModifier extends AbstractDrawModifier implements ModifierInterface public function apply(ImageInterface $image): ImageInterface { - return $image->eachFrame(function ($frame) { + return $image->mapFrames(function ($frame) { imageline( $frame->getCore(), $this->line()->getStart()->getX(), diff --git a/src/Drivers/Gd/Modifiers/DrawPixelModifier.php b/src/Drivers/Gd/Modifiers/DrawPixelModifier.php index f9010bf4..41ff41f6 100644 --- a/src/Drivers/Gd/Modifiers/DrawPixelModifier.php +++ b/src/Drivers/Gd/Modifiers/DrawPixelModifier.php @@ -23,7 +23,7 @@ class DrawPixelModifier implements ModifierInterface public function apply(ImageInterface $image): ImageInterface { $color = $this->handleInput($this->color); - return $image->eachFrame(function ($frame) use ($color) { + return $image->mapFrames(function ($frame) use ($color) { imagesetpixel( $frame->getCore(), $this->position->getX(), diff --git a/src/Drivers/Gd/Modifiers/DrawPolygonModifier.php b/src/Drivers/Gd/Modifiers/DrawPolygonModifier.php index f0cd77bb..48673317 100644 --- a/src/Drivers/Gd/Modifiers/DrawPolygonModifier.php +++ b/src/Drivers/Gd/Modifiers/DrawPolygonModifier.php @@ -20,7 +20,7 @@ class DrawPolygonModifier extends AbstractDrawModifier implements ModifierInterf public function apply(ImageInterface $image): ImageInterface { - return $image->eachFrame(function ($frame) { + return $image->mapFrames(function ($frame) { if ($this->polygon()->hasBackgroundColor()) { imagefilledpolygon( $frame->getCore(), diff --git a/src/Drivers/Gd/Modifiers/DrawRectangleModifier.php b/src/Drivers/Gd/Modifiers/DrawRectangleModifier.php index 2cc1653b..2c294afc 100644 --- a/src/Drivers/Gd/Modifiers/DrawRectangleModifier.php +++ b/src/Drivers/Gd/Modifiers/DrawRectangleModifier.php @@ -13,7 +13,7 @@ class DrawRectangleModifier extends AbstractDrawModifier implements ModifierInte public function apply(ImageInterface $image): ImageInterface { - $image->eachFrame(function ($frame) { + $image->mapFrames(function ($frame) { // draw background if ($this->rectangle()->hasBackgroundColor()) { imagefilledrectangle( diff --git a/src/Drivers/Imagick/Modifiers/DrawEllipseModifier.php b/src/Drivers/Imagick/Modifiers/DrawEllipseModifier.php index acaee3aa..3044efaf 100644 --- a/src/Drivers/Imagick/Modifiers/DrawEllipseModifier.php +++ b/src/Drivers/Imagick/Modifiers/DrawEllipseModifier.php @@ -18,7 +18,7 @@ class DrawEllipseModifier extends AbstractDrawModifier implements ModifierInterf $background_color = $this->colorToPixel($this->getBackgroundColor(), $colorspace); $border_color = $this->colorToPixel($this->getBorderColor(), $colorspace); - return $image->eachFrame(function ($frame) use ($background_color, $border_color) { + return $image->mapFrames(function ($frame) use ($background_color, $border_color) { $drawing = new ImagickDraw(); $drawing->setFillColor($background_color); diff --git a/src/Drivers/Imagick/Modifiers/DrawLineModifier.php b/src/Drivers/Imagick/Modifiers/DrawLineModifier.php index c5634869..ab67a0bd 100644 --- a/src/Drivers/Imagick/Modifiers/DrawLineModifier.php +++ b/src/Drivers/Imagick/Modifiers/DrawLineModifier.php @@ -27,7 +27,7 @@ class DrawLineModifier extends AbstractDrawModifier implements ModifierInterface $this->line()->getEnd()->getY(), ); - return $image->eachFrame(function ($frame) use ($drawing) { + return $image->mapFrames(function ($frame) use ($drawing) { $frame->getCore()->drawImage($drawing); }); } diff --git a/src/Drivers/Imagick/Modifiers/DrawPixelModifier.php b/src/Drivers/Imagick/Modifiers/DrawPixelModifier.php index 8651511c..078a34fa 100644 --- a/src/Drivers/Imagick/Modifiers/DrawPixelModifier.php +++ b/src/Drivers/Imagick/Modifiers/DrawPixelModifier.php @@ -33,7 +33,7 @@ class DrawPixelModifier implements ModifierInterface $pixel->setFillColor($this->colorToPixel($color, $image->getColorspace())); $pixel->point($this->position->getX(), $this->position->getY()); - return $image->eachFrame(function ($frame) use ($pixel) { + return $image->mapFrames(function ($frame) use ($pixel) { $frame->getCore()->drawImage($pixel); }); } diff --git a/src/Drivers/Imagick/Modifiers/DrawPolygonModifier.php b/src/Drivers/Imagick/Modifiers/DrawPolygonModifier.php index 695c83dd..0c14868f 100644 --- a/src/Drivers/Imagick/Modifiers/DrawPolygonModifier.php +++ b/src/Drivers/Imagick/Modifiers/DrawPolygonModifier.php @@ -37,7 +37,7 @@ class DrawPolygonModifier extends AbstractDrawModifier implements ModifierInterf $drawing->polygon($this->points()); - return $image->eachFrame(function ($frame) use ($drawing) { + return $image->mapFrames(function ($frame) use ($drawing) { $frame->getCore()->drawImage($drawing); }); } diff --git a/src/Drivers/Imagick/Modifiers/DrawRectangleModifier.php b/src/Drivers/Imagick/Modifiers/DrawRectangleModifier.php index 2f0c81ad..452bc64f 100644 --- a/src/Drivers/Imagick/Modifiers/DrawRectangleModifier.php +++ b/src/Drivers/Imagick/Modifiers/DrawRectangleModifier.php @@ -33,10 +33,8 @@ class DrawRectangleModifier extends AbstractDrawModifier implements ModifierInte $this->position->getY() + $this->rectangle()->bottomRightPoint()->getY() ); - $image->eachFrame(function ($frame) use ($drawing) { + return $image->mapFrames(function ($frame) use ($drawing) { $frame->getCore()->drawImage($drawing); }); - - return $image; } } diff --git a/src/Interfaces/ImageInterface.php b/src/Interfaces/ImageInterface.php index 31264d6f..b09ef526 100644 --- a/src/Interfaces/ImageInterface.php +++ b/src/Interfaces/ImageInterface.php @@ -31,7 +31,7 @@ interface ImageInterface extends Traversable, Countable * @param callable $callback * @return ImageInterface */ - public function eachFrame(callable $callback): ImageInterface; + public function mapFrames(callable $callback): ImageInterface; /** * Set loop count of animated image