PHP code example of ajaxray / php-watermark

1. Go to this page and download the library: Download ajaxray/php-watermark library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ajaxray / php-watermark example snippets


  
     // Initiate with source image or pdf
     $watermark = new Watermark('/path/to/source.jpg');
     
     // Customize some options (See list of supported options below)
     $watermark->withText('ajaxray.com')
        ->setFontSize(48)
        ->setRotate(30)
        ->setOpacity(.4)
        ->write('path/to/output.jpg');
     
     
     // Watermark with Image
     $watermark->withImage('path/to/logo.png')
        ->setPosition(Watermark::POSITION_BOTTOM_RIGHT)
        ->setStyle(Watermark::STYLE_IMG_DISSOLVE)
        ->write('path/to/output.jpg');
  

    ini_set('display_errors', 1);
    error_reporting(E_ALL);
    
bash
 $ composer 
bash
 $ composer 
bash
$ php vendor/ajaxray/php-watermark/examples/example_img.php
$ php vendor/ajaxray/php-watermark/examples/example_pdf.php