Water mark on a image in php

By Image ::


$watermark = imagecreatefrompng('select_sport.png');
$watermark_width = imagesx($watermark);
$watermark_height = imagesy($watermark);
$image = imagecreatetruecolor($watermark_width, $watermark_height);
$image = imagecreatefromjpeg('photo/Chrysanthemum.jpg');
$size = getimagesize('photo/Chrysanthemum.jpg');
$dest_x = $size[0] - $watermark_width - 50;
$dest_y = $size[1] - $watermark_height - 50;
imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 100);
imagejpeg($image, "photo/" . 'ok.jpg');  
imagedestroy($image);
imagedestroy($watermark);

By Text ::

$font_path = "ARIAL.TTF"; // Font file
$font_size = 20; // in pixcels
$water_mark_text_2 = 'http://www.sample.com'; // Watermark Text

$oldimage_name = 'photo/Chrysanthemum.jpg';
list($owidth,$oheight) = getimagesize($oldimage_name);
$width = $owidth; $height = $oheight; 
$image = imagecreatetruecolor($width, $height);
$image_src = imagecreatefromjpeg($oldimage_name);
imagecopyresampled($image, $image_src, 0, 0, 0, 0, $width, $height, $owidth, $oheight);
$blank = imagecolorallocate($image, 255, 255, 255);
$size = getimagesize($oldimage_name);
$dest_x = $size[0] - 350;
$dest_y = $size[1] - 50;
imagettftext($image, $font_size, 45, $dest_x, $dest_y, $blank, $font_path, $water_mark_text_2);
imagejpeg($image, "photo/" . 'ok.jpg'); 
imagedestroy($image);

Advertisements

Tagged: , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: