src/Manipulators/Watermark.php
public function run(Image $image)
    {
        if ($watermark = $this->getImage($image)) {
            $markw = $this->getDimension($image, 'markw');
            $markh = $this->getDimension($image, 'markh');
            $markx = $this->getDimension($image, 'markx');
            $marky = $this->getDimension($image, 'marky');
            $markpad = $this->getDimension($image, 'markpad');
            $markfit = $this->getFit();
            $markpos = $this->getPosition();
            $markalpha = $this->getAlpha();

            if ($markpad) {
                $markx = $marky = $markpad;
            }

            $size = new Size();
            $size->setParams([
                'w' => $markw,
                'h' => $markh,
                'fit' => $markfit,
            ]);
            $watermark = $size->run($watermark);

            if ($markalpha < 100) {
                $watermark->opacity($markalpha);
            }

            $image->insert($watermark, $markpos, intval($markx), intval($marky));
        }

        return $image;
    }
public function run(Image $image)
    {
        if ($watermark = $this->getImage($image)) {
            $markw = $this->getDimension($image, 'markw');
            $markh = $this->getDimension($image, 'markh');
            $markx = $this->getDimension($image, 'markx');
            $marky = $this->getDimension($image, 'marky');
            $markpad = $this->getDimension($image, 'markpad');
            $markfit = $this->getFit();
            $markpos = $this->getPosition();
            $markalpha = $this->getAlpha();

            if ($markpad) {
                $markx = $marky = $markpad;
            }

            $size = new Size();
            $size->setParams([
                'w' => $markw,
                'h' => $markh,
                'fit' => $markfit,
            ]);
            $watermark = $size->run($watermark);

            if ($markalpha < 100) {
                $watermark->opacity($markalpha);
            }

            $image->insert($watermark, $markpos, intval($markx), intval($marky));
        }

        return $image;
    }
public function run ( Image $ image ) { if ( $ watermark = $ this -> getImage ( $ image ) ) { $ markw = $ this -> getDimension ( $ image , 'markw' ) ; $ markh = $ this -> getDimension ( $ image , 'markh' ) ; $ markx = $ this -> getDimension ( $ image , 'markx' ) ; $ marky = $ this -> getDimension ( $ image , 'marky' ) ; $ markpad = $ this -> getDimension ( $ image , 'markpad' ) ; $ markfit = $ this -> getFit ( ) ; $ markpos = $ this -> getPosition ( ) ; $ markalpha = $ this -> getAlpha ( ) ; if ( $ markpad ) { $ markx = $ marky = $ markpad ; } $ size = new Size ( ) ; $ size -> setParams ( [ 'w' => $ markw , 'h' => $ markh , 'fit' => $ markfit , ] ) ; $ watermark = $ size -> run ( $ watermark ) ; if ( $ markalpha < 100 ) { $ watermark -> opacity ( $ markalpha ) ; } $ image -> insert ( $ watermark , $ markpos , intval ( $ markx ) , intval ( $ marky ) ) ; } return $ image ; }
Perform watermark image manipulation.
@param  Image $image The source image.
@return Image The manipulated image.
Perform watermark image manipulation .