From cdee873d8a02dc8355d6548b1c7fade0543a3d6a Mon Sep 17 00:00:00 2001 From: Oliver Vogel Date: Fri, 29 Sep 2023 17:06:31 +0200 Subject: [PATCH] Change code examples and requirements in readme --- readme.md | 4 +-- src/Interfaces/ImageInterface.php | 43 ++++++++++++++++++++++++++----- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/readme.md b/readme.md index 7704f23e1..0cd1f4d54 100644 --- a/readme.md +++ b/readme.md @@ -23,7 +23,7 @@ $manager = new ImageManager('gd') $image = $manager->make('images/example.gif'); // resize image instance -$image->resize(320, 240); +$image->resize(height: 300); // insert a watermark $image->place('images/watermark.png'); @@ -37,7 +37,7 @@ $encoded->save('images/example.jpg'); ## Requirements -- PHP >=8.0 +- PHP >= 8.1 ## Supported Image Libraries diff --git a/src/Interfaces/ImageInterface.php b/src/Interfaces/ImageInterface.php index 34262ad3a..2e28106fa 100644 --- a/src/Interfaces/ImageInterface.php +++ b/src/Interfaces/ImageInterface.php @@ -103,6 +103,16 @@ public function toPng(): EncodedImage; public function pickColor(int $x, int $y, int $frame_key = 0): ?ColorInterface; public function pickColors(int $x, int $y): CollectionInterface; + + /** + * Draw text on image + * + * @param string $text + * @param int $x + * @param int $y + * @param null|callable $init + * @return ImageInterface + */ public function text(string $text, int $x, int $y, ?callable $init = null): ImageInterface; /** @@ -120,8 +130,29 @@ public function greyscale(): ImageInterface; * @return ImageInterface */ public function blur(int $amount = 5): ImageInterface; + + + /** + * Rotate current image by given angle + * + * @param float $angle + * @param string $background + * @return ImageInterface + */ public function rotate(float $angle, $background = 'ffffff'): ImageInterface; + + + /** + * Place another image into the current image instance + * + * @param mixed $element + * @param string $position + * @param int $offset_x + * @param int $offset_y + * @return ImageInterface + */ public function place($element, string $position = 'top-left', int $offset_x = 0, int $offset_y = 0): ImageInterface; + public function fill($color, ?int $x = null, ?int $y = null): ImageInterface; public function pixelate(int $size): ImageInterface; public function resize(?int $width = null, ?int $height = null): ImageInterface; @@ -138,9 +169,9 @@ public function drawRectangle(int $x, int $y, ?callable $init = null): ImageInte /** * Draw ellipse ot given position on current image * - * @param int $x - * @param int $y - * @param null|callable $init + * @param int $x + * @param int $y + * @param null|callable $init * @return ImageInterface */ public function drawEllipse(int $x, int $y, ?callable $init = null): ImageInterface; @@ -148,7 +179,7 @@ public function drawEllipse(int $x, int $y, ?callable $init = null): ImageInterf /** * Draw line on image * - * @param callable|null $init + * @param callable|null $init * @return ImageInterface */ public function drawLine(callable $init = null): ImageInterface; @@ -156,7 +187,7 @@ public function drawLine(callable $init = null): ImageInterface; /** * Draw polygon on image * - * @param callable|null $init + * @param callable|null $init * @return ImageInterface */ public function drawPolygon(callable $init = null): ImageInterface; @@ -164,7 +195,7 @@ public function drawPolygon(callable $init = null): ImageInterface; /** * Sharpen the current image with given strength * - * @param int $amount + * @param int $amount * @return ImageInterface */ public function sharpen(int $amount = 10): ImageInterface;