From 834d5cb2ba39900d1b6c2dc9f71120d5387194dc Mon Sep 17 00:00:00 2001 From: Oliver Vogel Date: Fri, 29 Sep 2023 16:14:11 +0200 Subject: [PATCH] Rename parameter --- src/Drivers/Gd/Image.php | 4 +-- src/Drivers/Imagick/Image.php | 4 +-- src/Interfaces/ImageInterface.php | 43 ++++++++++++++++++++++++++++++- 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/src/Drivers/Gd/Image.php b/src/Drivers/Gd/Image.php index fdacd9d7..ad9b3754 100644 --- a/src/Drivers/Gd/Image.php +++ b/src/Drivers/Gd/Image.php @@ -44,9 +44,9 @@ class Image extends AbstractImage implements ImageInterface, IteratorAggregate return $this; } - public function getFrame(int $key = 0): ?FrameInterface + public function getFrame(int $position = 0): ?FrameInterface { - return $this->frames->get($key); + return $this->frames->get($position); } public function addFrame(FrameInterface $frame): ImageInterface diff --git a/src/Drivers/Imagick/Image.php b/src/Drivers/Imagick/Image.php index e7b2a9ab..e5cf937f 100644 --- a/src/Drivers/Imagick/Image.php +++ b/src/Drivers/Imagick/Image.php @@ -24,10 +24,10 @@ class Image extends AbstractImage implements ImageInterface, Iterator return $this->imagick; } - public function getFrame(int $key = 0): ?FrameInterface + public function getFrame(int $position = 0): ?FrameInterface { try { - $this->imagick->setIteratorIndex($key); + $this->imagick->setIteratorIndex($position); } catch (ImagickException $e) { return null; } diff --git a/src/Interfaces/ImageInterface.php b/src/Interfaces/ImageInterface.php index 9f4220bb..0eac33c3 100644 --- a/src/Interfaces/ImageInterface.php +++ b/src/Interfaces/ImageInterface.php @@ -8,18 +8,59 @@ use Traversable; interface ImageInterface extends Traversable, Countable { - public function getFrame(int $key = 0): ?FrameInterface; + /** + * Get frame of animation image at given position starting with zero + * + * @param int $key + * @return null|FrameInterface + */ + public function getFrame(int $position = 0): ?FrameInterface; public function addFrame(FrameInterface $frame): ImageInterface; public function setLoops(int $count): ImageInterface; public function getLoops(): int; public function getSize(): SizeInterface; public function isAnimated(): bool; public function modify(ModifierInterface $modifier): ImageInterface; + + /** + * Encode image with given encoder + * + * @param EncoderInterface $encoder + * @return EncodedImage + */ public function encode(EncoderInterface $encoder): EncodedImage; + + /** + * Encode image to jpeg format + * + * @param int $quality + * @return EncodedImage + */ public function toJpeg(int $quality = 75): EncodedImage; + + /** + * Encode image to webp format + * + * @param int $quality + * @return EncodedImage + */ public function toWebp(int $quality = 75): EncodedImage; + + /** + * Encode image to gif format + * + * @return EncodedImage + */ public function toGif(): EncodedImage; + + + /** + * Encode image to png format + * + * @return EncodedImage + */ public function toPng(): EncodedImage; + public function pickColors(int $x, int $y): CollectionInterface; public function text(string $text, int $x, int $y, ?callable $init = null): ImageInterface; public function pickColor(int $x, int $y, int $frame_key = 0): ?ColorInterface;