private function applyWatermarkImagick(Imagick $image)
    {
        $pictureWidth  = $image->getImageWidth();
        $pictureHeight = $image->getImageHeight();

        $watermarkPicture = new Picture($this->watermark, NULL, Picture::WORKER_IMAGICK);

        $opacity = new Opacity($this->opacity);
        $opacity->apply($watermarkPicture);

        if($this->size)
        {
            $resize = new Resize(
                $pictureWidth / 100 * $this->size,
                $pictureHeight / 100 * $this->size,
                Resize::MODE_FIT
            );

            $resize->apply($watermarkPicture);
        }

        $watermark = $watermarkPicture->getResource(Picture::WORKER_IMAGICK);

        $watermarkWidth  = $watermark->getImageWidth();
        $watermarkHeight = $watermark->getImageHeight();

        switch($this->position)
        {
            case 'repeat':

                for($w = 0; $w < $pictureWidth; $w += $watermarkWidth + $this->space)
                {
                    for($h = 0; $h < $pictureHeight; $h += $watermarkHeight + $this->space)
                    {
                        $image->compositeImage($watermark, $watermark->getImageCompose(), $w, $h);
                    }
                }
                return;

            case 'center':

                $positionX = ($image->getImageWidth() - $watermark->getImageWidth()) / 2 - $this->offsetX;
                $positionY = ($image->getImageHeight() - $watermark->getImageHeight()) / 2 - $this->offsetY;
                break;

            case 'topRight':

                $positionX = $image->getImageWidth() - $watermark->getImageWidth() - $this->offsetX;
                $positionY = $this->offsetY;
                break;

            case 'bottomRight':

                $positionX = $image->getImageWidth()  - $watermark->getImageWidth()  - $this->offsetX;
                $positionY = $image->getImageHeight() - $watermark->getImageHeight() - $this->offsetY;
                break;

            case 'bottomLeft':

                $positionX = $this->offsetX;
                $positionY = $image->getImageHeight() - $watermark->getImageHeight() - $this->offsetY;
                break;

            default:

                $positionX = $this->offsetX;
                $positionY = $this->offsetY;
                break;
        }

        $image->compositeImage($watermark, $watermark->getImageCompose(), $positionX, $positionY);
    }
private function applyWatermarkImagick(Imagick $image)
    {
        $pictureWidth  = $image->getImageWidth();
        $pictureHeight = $image->getImageHeight();

        $watermarkPicture = new Picture($this->watermark, NULL, Picture::WORKER_IMAGICK);

        $opacity = new Opacity($this->opacity);
        $opacity->apply($watermarkPicture);

        if($this->size)
        {
            $resize = new Resize(
                $pictureWidth / 100 * $this->size,
                $pictureHeight / 100 * $this->size,
                Resize::MODE_FIT
            );

            $resize->apply($watermarkPicture);
        }

        $watermark = $watermarkPicture->getResource(Picture::WORKER_IMAGICK);

        $watermarkWidth  = $watermark->getImageWidth();
        $watermarkHeight = $watermark->getImageHeight();

        switch($this->position)
        {
            case 'repeat':

                for($w = 0; $w < $pictureWidth; $w += $watermarkWidth + $this->space)
                {
                    for($h = 0; $h < $pictureHeight; $h += $watermarkHeight + $this->space)
                    {
                        $image->compositeImage($watermark, $watermark->getImageCompose(), $w, $h);
                    }
                }
                return;

            case 'center':

                $positionX = ($image->getImageWidth() - $watermark->getImageWidth()) / 2 - $this->offsetX;
                $positionY = ($image->getImageHeight() - $watermark->getImageHeight()) / 2 - $this->offsetY;
                break;

            case 'topRight':

                $positionX = $image->getImageWidth() - $watermark->getImageWidth() - $this->offsetX;
                $positionY = $this->offsetY;
                break;

            case 'bottomRight':

                $positionX = $image->getImageWidth()  - $watermark->getImageWidth()  - $this->offsetX;
                $positionY = $image->getImageHeight() - $watermark->getImageHeight() - $this->offsetY;
                break;

            case 'bottomLeft':

                $positionX = $this->offsetX;
                $positionY = $image->getImageHeight() - $watermark->getImageHeight() - $this->offsetY;
                break;

            default:

                $positionX = $this->offsetX;
                $positionY = $this->offsetY;
                break;
        }

        $image->compositeImage($watermark, $watermark->getImageCompose(), $positionX, $positionY);
    }
private function applyWatermarkImagick ( Imagick $ image ) { $ pictureWidth = $ image -> getImageWidth ( ) ; $ pictureHeight = $ image -> getImageHeight ( ) ; $ watermarkPicture = new Picture ( $ this -> watermark , NULL , Picture :: WORKER_IMAGICK ) ; $ opacity = new Opacity ( $ this -> opacity ) ; $ opacity -> apply ( $ watermarkPicture ) ; if ( $ this -> size ) { $ resize = new Resize ( $ pictureWidth / 100 * $ this -> size , $ pictureHeight / 100 * $ this -> size , Resize :: MODE_FIT ) ; $ resize -> apply ( $ watermarkPicture ) ; } $ watermark = $ watermarkPicture -> getResource ( Picture :: WORKER_IMAGICK ) ; $ watermarkWidth = $ watermark -> getImageWidth ( ) ; $ watermarkHeight = $ watermark -> getImageHeight ( ) ; switch ( $ this -> position ) { case 'repeat' : for ( $ w = 0 ; $ w < $ pictureWidth ; $ w += $ watermarkWidth + $ this -> space ) { for ( $ h = 0 ; $ h < $ pictureHeight ; $ h += $ watermarkHeight + $ this -> space ) { $ image -> compositeImage ( $ watermark , $ watermark -> getImageCompose ( ) , $ w , $ h ) ; } } return ; case 'center' : $ positionX = ( $ image -> getImageWidth ( ) - $ watermark -> getImageWidth ( ) ) / 2 - $ this -> offsetX ; $ positionY = ( $ image -> getImageHeight ( ) - $ watermark -> getImageHeight ( ) ) / 2 - $ this -> offsetY ; break ; case 'topRight' : $ positionX = $ image -> getImageWidth ( ) - $ watermark -> getImageWidth ( ) - $ this -> offsetX ; $ positionY = $ this -> offsetY ; break ; case 'bottomRight' : $ positionX = $ image -> getImageWidth ( ) - $ watermark -> getImageWidth ( ) - $ this -> offsetX ; $ positionY = $ image -> getImageHeight ( ) - $ watermark -> getImageHeight ( ) - $ this -> offsetY ; break ; case 'bottomLeft' : $ positionX = $ this -> offsetX ; $ positionY = $ image -> getImageHeight ( ) - $ watermark -> getImageHeight ( ) - $ this -> offsetY ; break ; default : $ positionX = $ this -> offsetX ; $ positionY = $ this -> offsetY ; break ; } $ image -> compositeImage ( $ watermark , $ watermark -> getImageCompose ( ) , $ positionX , $ positionY ) ; }
Watermark effect processed by Imagick
@param Imagick $image
Watermark effect processed by Imagick