Public feed #726294

Mine

public text v1 · immutable
Raw Edit
·published 2007-10-05 01:47 UTC
rendered paste body
<?PHP
/**********************************************
* Add NRMA PNG watermark to webcam/radar images.
* - Tim Sheehan 4th October 2007.
* - Set image to be altered.
* - Set watermark image.
* - Set directory of image to be altered.
*/

// Name of the file to have watermark applied to.
$file_name="watermarkme.jpg";

// Path to the source of the file to be watermarked.
$add="images/$file_name"; 

// Destination to send watermarked image to.
$add2="images/$file_name";

// Name of watermark file. (PNG ONLY)
$water_img="ad.png"; 

// Read source files image size.
$img_ar=GetImageSize ($add); 

// Read watermark image size.
$img_wt_ar=GetImageSize ($water_img);

// Location of watermark on source image by pixel (top to bottom).
$location_height=380;

// Location of watermark on source image by pixel (left to right).
$location_width=300; // Location of water mark

// Source file creation, if there is a need change the file type
// you must alter ImageCreateFromJpeg to read ImageCreateFromGIF etc.
$im=ImageCreateFromJpeg($add);

// Watermark file insertion, if there is a need change the file type
// you must alter ImageCreateFrompng to read ImageCreateFromgif etc.
$water_img1=ImageCreateFrompng($water_img);

// Creating new image etc.
$newimage=imagecreatetruecolor($img_ar[0],$img_ar[1]);//
imageCopyResized($newimage,$im,0,0,0,0,$img_ar[0],$img_ar[1],
$img_ar[0],$img_ar[1]);
$t=ImageCopy($newimage,$water_img1,$location_width,$location_height,
0,0,$img_wt_ar[0],$img_wt_ar[1]);

ImageJpeg($newimage,$add2,100);
chmod("$add2",0666);

// Output (Custom)
print "<br /><br /><center>";
print "<table width='500px' border='0' bordercolor='#dddddd' bgcolor='#eeeeee' callpadding='4'><tr><td>";
print "<font face='tahoma' size='2'>You have successfully placed a watermark on $file_name - view image below.<br /> <br /> <br /></font>";
print "</td></tr><tr><td>";
print "<center><img src='images/$file_name' /></center>";
print "</td></tr></table></center>";
?>