• PHP Image and Text Watermark

    Text watermark function, here you have to configure font source, size and text.

    1
    
     

    Watermark with Image – watermark_image()

    Image watermark function, here you have to configure image water mark source.

    $image_path = “test.png”; // image path

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    
    function watermark_image($oldimage_name, $new_image_name)
     
    {
     
    global $image_path;
     
    list($owidth,$oheight) = getimagesize($oldimage_name);
     
    $width = $height = 300; 
     
    $im = imagecreatetruecolor($width, $height);
     
    $img_src = imagecreatefromjpeg($oldimage_name);
     
    imagecopyresampled($im, $img_src, 0, 0, 0, 0, $width, $height, $owidth, $oheight);
     
    $watermark = imagecreatefrompng($image_path);
     
    list($w_width, $w_height) = getimagesize($image_path); 
     
    $pos_x = $width - $w_width; 
     
    $pos_y = $height - $w_height;
     
    imagecopy($im, $watermark, $pos_x, $pos_y, 0, 0, $w_width, $w_height);
     
    imagejpeg($im, $new_image_name, 100);
     
    imagedestroy($im);
     
    unlink($oldimage_name);
     
    return true;
     
    }

    Image Form

    Contains simple PHP and HTML form submit code. Here HTML form sending post request.

    1
    
     

    // HTML Code

    Upload Image Image :
    ‘; ?>

Comments on this post

Leave a Reply

  • Security Code :


    × 6 = twenty four