Search code examples
phpimage-processingimagemagickimagickwatermark

PHP Imagick compositeImage set position


I use the Imagick library for Image processing.

I'm using this function: https://php.net/manual/ro/imagick.compositeimage.php

How can I place the second image above the first image in the left corner for example? I'm using this function to add a watermark above all images. But the watermark is centered on all images. I just wat to align it in the bottom-left side of the image.

Any idea? Thanks.


Solution

  • The fix was to edit the width and the height from the function compositeImage (last two parameters).

    bool Imagick::compositeImage ( Imagick $composite_object , int $composite , int $x , int $y [, int $channel = Imagick::CHANNEL_ALL ] )

    I guess that setGravity might help, but changing the width and the height sent to "compositeImage" did the job for me.