From 2c20475c1c506cd85f5d894ae317adb02df15eb9 Mon Sep 17 00:00:00 2001 From: Tobias Klug Date: Mon, 27 Mar 2017 14:25:51 +0200 Subject: [PATCH] add new modes bottom, top, right, left to watermark transformation --- src/Image/Transformation/Watermark.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Image/Transformation/Watermark.php b/src/Image/Transformation/Watermark.php index 246cc4611..84a5e722b 100644 --- a/src/Image/Transformation/Watermark.php +++ b/src/Image/Transformation/Watermark.php @@ -55,6 +55,10 @@ class Watermark extends Transformation implements ListenerInterface { * - "top-right": Places the watermark in the top right corner * - "bottom-left": Places the watermark in the bottom left corner * - "bottom-right": Places the watermark in the bottom right corner + * - "bottom": Places the watermark in the bottom center + * - "top": Places the watermark in the top center + * - "right": Places the watermark in the right center + * - "left": Places the watermark in the left center * - "center": Places the watermark in the center of the image * * @var string @@ -170,6 +174,16 @@ public function transform(EventInterface $event) { } else if ($position === 'center') { $x = ($image->getWidth() / 2) - ($width / 2) + $x; $y = ($image->getHeight() / 2) - ($height / 2) + $y; + } else if ($position === 'bottom') { + $x = ($image->getWidth() / 2) - ($width / 2) + $x; + $y = $image->getHeight() - $height + $y; + } else if ($position === 'top') { + $x = ($image->getWidth() / 2) - ($width / 2) + $x; + } else if ($position === 'left') { + $y = ($image->getHeight() / 2) - ($height / 2) + $y; + } else if ($position === 'right') { + $x = $image->getWidth() - $width + $x; + $y = ($image->getHeight() / 2) - ($height / 2) + $y; } // Now make a composite