public function watermark($watermarkFile, $corner = self::IMG_RIGHT_BOTTOM_CORNER, $offsetX = 10, $offsetY = 10)
    {
        // The very first thing we gotta do is to load watermark's image file
        $watermark = new ImageFile($watermarkFile);

        // Initial positioning
        $x = 0;
        $y = 0;

        // Walk through supported values
        switch ($corner) {

            case self::IMG_RIGHT_BOTTOM_CORNER:
                $x = $this->width - $watermark->getWidth() - $offsetX;
                $y = $this->height - $watermark->getHeight() - $offsetY;
            break;

            case self::IMG_RIGHT_TOP:
                $x = $this->width - $watermark->getWidth() - $offsetX;
                $y = $offsetY;
            break;

            case self::IMG_LEFT_CORNER:
                $x = $offsetX;
                $y = $offsetY;
            break;

            case self::IMG_LEFT_BOTTOM_CORNER:
                $x = $offsetX;
                $y = $this->height - $watermark->getHeight() - $offsetY;
            break;

            case self::CORNER_CENTER:
                $x = floor(($this->width - $watermark->getWidth()) / 2);
                $y = floor(($this->height - $watermark->getHeight()) / 2);
            break;

            default:
                throw new UnexpectedValueException(sprintf("Unexpected corner's value provided '%s'", $corner));
        }

        // Done with calculations. Now add a watermark on the original loaded image
        imagecopy($this->image, $watermark->getImage(), $x, $y, 0, 0, $watermark->getWidth(), $watermark->getHeight());

        // Free memory now
        unset($watermark);

        return $this;
    }
public function watermark($watermarkFile, $corner = self::IMG_RIGHT_BOTTOM_CORNER, $offsetX = 10, $offsetY = 10)
    {
        // The very first thing we gotta do is to load watermark's image file
        $watermark = new ImageFile($watermarkFile);

        // Initial positioning
        $x = 0;
        $y = 0;

        // Walk through supported values
        switch ($corner) {

            case self::IMG_RIGHT_BOTTOM_CORNER:
                $x = $this->width - $watermark->getWidth() - $offsetX;
                $y = $this->height - $watermark->getHeight() - $offsetY;
            break;

            case self::IMG_RIGHT_TOP:
                $x = $this->width - $watermark->getWidth() - $offsetX;
                $y = $offsetY;
            break;

            case self::IMG_LEFT_CORNER:
                $x = $offsetX;
                $y = $offsetY;
            break;

            case self::IMG_LEFT_BOTTOM_CORNER:
                $x = $offsetX;
                $y = $this->height - $watermark->getHeight() - $offsetY;
            break;

            case self::CORNER_CENTER:
                $x = floor(($this->width - $watermark->getWidth()) / 2);
                $y = floor(($this->height - $watermark->getHeight()) / 2);
            break;

            default:
                throw new UnexpectedValueException(sprintf("Unexpected corner's value provided '%s'", $corner));
        }

        // Done with calculations. Now add a watermark on the original loaded image
        imagecopy($this->image, $watermark->getImage(), $x, $y, 0, 0, $watermark->getWidth(), $watermark->getHeight());

        // Free memory now
        unset($watermark);

        return $this;
    }
public function watermark ( $ watermarkFile , $ corner = self :: IMG_RIGHT_BOTTOM_CORNER , $ offsetX = 10 , $ offsetY = 10 ) { // The very first thing we gotta do is to load watermark's image file $ watermark = new ImageFile ( $ watermarkFile ) ; // Initial positioning $ x = 0 ; $ y = 0 ; // Walk through supported values switch ( $ corner ) { case self :: IMG_RIGHT_BOTTOM_CORNER : $ x = $ this -> width - $ watermark -> getWidth ( ) - $ offsetX ; $ y = $ this -> height - $ watermark -> getHeight ( ) - $ offsetY ; break ; case self :: IMG_RIGHT_TOP : $ x = $ this -> width - $ watermark -> getWidth ( ) - $ offsetX ; $ y = $ offsetY ; break ; case self :: IMG_LEFT_CORNER : $ x = $ offsetX ; $ y = $ offsetY ; break ; case self :: IMG_LEFT_BOTTOM_CORNER : $ x = $ offsetX ; $ y = $ this -> height - $ watermark -> getHeight ( ) - $ offsetY ; break ; case self :: CORNER_CENTER : $ x = floor ( ( $ this -> width - $ watermark -> getWidth ( ) ) / 2 ) ; $ y = floor ( ( $ this -> height - $ watermark -> getHeight ( ) ) / 2 ) ; break ; default : throw new UnexpectedValueException ( sprintf ( "Unexpected corner's value provided '%s'" , $ corner ) ) ; } // Done with calculations. Now add a watermark on the original loaded image imagecopy ( $ this -> image , $ watermark -> getImage ( ) , $ x , $ y , 0 , 0 , $ watermark -> getWidth ( ) , $ watermark -> getHeight ( ) ) ; // Free memory now unset ( $ watermark ) ; return $ this ; }
Adds a watermark on current image

@param string $watermarkFile Path to watermark file
@param integer $corner Corner's position (Which is usually represented via constants)
@param integer $offsetX Offset X
@param integer $offsetY Offset Y
@return \Krystal\Image\Processor\GD\ImageProcessor
Adds a watermark on current image