< Buzzing or vibrating the login form using jquery Posted On May 15, 2012 : 0 comments << >> Simple div slideshow using jquery Posted On May 9, 2012 : 0 comments << >> Copy mysql column in varchar to type date Posted On May 3, 2012 : 0 comments << >> Enter only numbers inside a input field of a form using javascript Posted On May 1, 2012 : 0 comments << >> Slide in and out animate div vertically using jquery Posted On April 25, 2012 : 1 comment << >> Tag cloud using php, mysql and ajax with filter Posted On April 24, 2012 : 0 comments << >> Change webpage font color or background color from the user side using javascript Posted On April 19, 2012 : 0 comments << >> A single link that cycles through several webpage background color using javascript Posted On April 17, 2012 : 0 comments << >> Simple webpage redirection using perl script Posted On April 10, 2012 : 0 comments << >> Get ipaddress using perl script Posted On April 4, 2012 : 0 comments << >>

Simple php watermark script

This Tutorial Has Been Viewed 2,299 Times.
VN:F [1.9.17_1161]
Rating: 5.2/10 (5 votes cast)

A very simple script that watermarks an image with a PNG file using php.Just save the below script and run it on your browser.Thats it.Make sure of the path [image and thePNG watermark]

< ?php
//just save this file as <sumname>.php and run this in your website or locahost//make sure the path specified for your image and the watermark png is corectfunction watermark($sourcefile, $watermarkfile) {
# $sourcefile    = Filename of the picture to be watermarked.

# $watermarkfile   = Filename of the 24-bit PNG watermark file.

//Get the resource ids of the pictures

$watermarkfile_id   = imagecreatefrompng($watermarkfile);

imageAlphaBlending($watermarkfile_id, false);

imageSaveAlpha($watermarkfile_id, true);

$fileType = strtolower(substr($sourcefile, strlen($sourcefile)-3));

switch($fileType) {

case("gif"):

$sourcefile_id = imagecreatefromgif($sourcefile);

break;

case("png"):

$sourcefile_id = imagecreatefrompng($sourcefile);

break;

default:

$sourcefile_id = imagecreatefromjpeg($sourcefile);

}

//Get the sizes of both pix

$sourcefile_width   = imageSX($sourcefile_id);

$sourcefile_height   = imageSY($sourcefile_id);

$watermarkfile_width   = imageSX($watermarkfile_id);

$watermarkfile_height   = imageSY($watermarkfile_id);

$dest_x     = ( $sourcefile_width / 2 ) – ( $watermarkfile_width / 2 );

$dest_y     = ( $sourcefile_height / 2 ) – ( $watermarkfile_height / 2 );

// if a gif, we have to upsample it to a truecolor image

if($fileType == "gif") {

// create an empty truecolor container

$tempimage = imagecreatetruecolor($sourcefile_width, $sourcefile_height);

// copy the 8-bit gif into the truecolor image

imagecopy($tempimage, $sourcefile_id, 0, 0, 0, 0, $sourcefile_width, $sourcefile_height);// copy the source_id int

$sourcefile_id = $tempimage;

}

imagecopy($sourcefile_id, $watermarkfile_id, $dest_x, $dest_y, 0, 0, $watermarkfile_width, $watermarkfile_height);

//Create a jpeg out of the modified picture

switch($fileType) {

// remember we do not need gif any more, so we use only png or jpeg.

// See the code above to see how we handle gifs

case("png"):

header("Content-type: image/png");

imagepng ($sourcefile_id);

break;

default:

header("Content-type: image/jpg");

imagejpeg ($sourcefile_id);

}

imagedestroy($sourcefile_id);

imagedestroy($watermarkfile_id);

}

watermark("mypic.jpg","logo.png");

?>
VN:F [1.9.17_1161]
Rating: 5.2/10 (5 votes cast)

Simple php watermark script, 5.2 out of 10 based on 5 ratings

Incoming search terms:





You will also be interested in ,

Tags: ,

Leave a Reply

Proudly designed by Mistonline.in.
Affordable Seo PackagesSeo BlogEdu Backlinks