Permalink
Browse files

add new modes bottom, top, right, left to watermark transformation

  • Loading branch information...
Tobias Klug authored and christeredvartsen committed Mar 27, 2017
1 parent 2c27041 commit 70baea9cb9d42882b2a62607fdcb41c2fd1bf94c
Showing with 14 additions and 0 deletions.
  1. +14 −0 src/Image/Transformation/Watermark.php
@@ -54,6 +54,10 @@ class Watermark extends Transformation implements InputSizeConstraint {
* - "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
@@ -157,6 +161,16 @@ public function transform(array $params) {
} 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

0 comments on commit 70baea9

Please sign in to comment.