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");
?>
Incoming search terms:
- php watermark script (42)
- php watermark (10)
- watermark php script (9)
- php watermark tutorial (9)
- simple php watermark (8)
- watermark script php (5)
- video watermark script php (4)
- php simple watermark (4)
- simple watermark php (4)
- Making an Ajax PHP Watermarker Script (4)
- mpdf watermark (4)
- php video watermarking script (3)
- easy watermark php (3)
- simple watermark script (2)
- php script watermark text (2)
- php video watermark script (2)
- php wasserzeichen 2011 tutorial (2)
- simple water mark in php (2)
- script php watermark (2)
- watermark image simple code in php (2)
- watermark with php single file (2)
- adding water mark to excel file using php or cript (2)
- watermark php (2)
- watermark script in php (2)
- simple php watermark logo (1)
- simple php watermark script (1)
- watermark text image in php code (1)
- Simple video watermark script (1)
- watermark simple php script (1)
- simple water mark script (1)
- watermark simple php (1)
- php watermarking video script (1)
- Simple Image WaterMark php (1)
- php:watermark script (1)
- phpwatermark video online (1)
- script in php to add watermark to a video (1)
- script php apache watermark (1)
- Watermark Your Image With Simple Php Script (1)
- simple php watermark with filename (1)
- script watemark php (1)
You will also be interested in ,
- View edit and save text file database using php
- Simple Example Of Database Connection Using PEAR In PHP
- Avoid direct access to a file in php enhanced version
- Simple auto suggest script using ajax php css and tags from wordpress
- Water mark images using PHP 5 and GD Library
- Send Email to Multiple Persons using php
- Creating a simple class file using PHP
- Find Absolute Path Of A File Or Directory Using PHP
- How to run or Configure Apache to use PHP as CGI
- Locking a text file database using php

