diff --git a/src/Drivers/Gd/Image.php b/src/Drivers/Gd/Image.php index fdacd9d73..ad9b3754d 100644 --- a/src/Drivers/Gd/Image.php +++ b/src/Drivers/Gd/Image.php @@ -44,9 +44,9 @@ public function setLoops(int $count): self 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 e7b2a9ab0..e5cf937f4 100644 --- a/src/Drivers/Imagick/Image.php +++ b/src/Drivers/Imagick/Image.php @@ -24,10 +24,10 @@ public function getImagick(): Imagick 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 9f4220bb5..0eac33c3c 100644 --- a/src/Interfaces/ImageInterface.php +++ b/src/Interfaces/ImageInterface.php @@ -8,18 +8,59 @@ 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;