Skip to content

Commit

Permalink
add new modes bottom, top, right, left to watermark transformation
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Klug committed Mar 27, 2017
1 parent 8bff9d6 commit 2c20475
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Image/Transformation/Watermark.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2c20475

Please sign in to comment.