0

I am trying to watermark images using the Imagine library (on a CakePHP project). Cropping images works fine - watermarking does not. I use the example from the Imagine website:

$imagine = new Imagine\Gd\Imagine();

$watermark = $imagine->open('/my/watermark.png');
$image     = $imagine->open('/path/to/image.jpg');
$size      = $image->getSize();
$wSize     = $watermark->getSize();

$bottomRight = new Imagine\Image\Point($size->getX() - $wSize->getX(), $size->getY() - $wSize->getY());

$image->paste($watermark, $bottomRight);

The original example doesn't state an instantiation procedure, so I added what I found on the page. Doing so yields the following error:

 Call to undefined method Imagine\Image\Box::getX() 

How do I use it correctly?

olli
  • 3
  • 6

2 Answers2

0

I've used it like this and it's worked.

\Imagine\Image\Box::getX()

test it please

0

Replace this:

    $bottomRight = new Imagine\Image\Point($size->getX() - $wSize->getX(), $size->getY() - $wSize->getY());

With this:

    $bottomRight = new \Imagine\Image\Point($size->getWidth() - $wSize->getWidth(), $size->getHeight() - $wSize->getHeight());
David Jones
  • 4,275
  • 6
  • 27
  • 51
Alex Agrazal
  • 53
  • 2
  • 8