php image watermark

Posted by midhun pottmmal On Friday, 28 December 2012 0 comments

   
 This article shares a few pointers on what makes an effective watermark, and then shows you how to use the GD functions to add a watermark to your image. Before you get started, make sure that Php GD library is available on your host. 


Watermark code


 


    list($owidth,$oheight) = getimagesize($oldimage_name);
    $width = $height = 400;    
    $image = imagecreatetruecolor($width, $height);
    $image_src = imagecreatefromjpeg($oldimage_name);
    imagecopyresampled($image, $image_src, 0, 0, 0, 0, $width, $height, $owidth, $oheight);
    $colour = imagecolorallocate($image, 0, 0, 0);
   
    imagettftext($image, $font_size, 0,5, 190, $colour, $font_path, $watermark_text);
    imagejpeg($image, $new_image_name, 100);
    imagedestroy($image);
    unlink($oldimage_name);

form code


<form name="imageUpload" id="imageUpload" method="post"
                  enctype="multipart/form-data" >
            
 Image :<input type="file" name="imgfile" id="imgfile"/><br />
 <input type="submit" name="createmark" id="createmark" value="Submit" />

Download

download source














0 comments:

Post a Comment

Fashion