How to use PHP & Upload and Write Logo to image (Watermark) The guideline/example scripts how to using PHP and GD , Upload and Write Logo to image (Watermark)
ShotDev Focus:
- PHP & GD (Upload and Write Logo to image (Watermark))
Example
php_write_logo_picture1.php
<html> <head> <title>ShotDev.Com Tutorial</title> </head> <body> <form action="php_write_logo_picture2.php" method="post" enctype="multipart/form-data" name="frmMain"> <table width="343" border="1"> <tr> <td>Upload</td> <td><input name="fileUpload" type="file"></td> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" value="Submit"></td> </tr> </table> </form> </body> </html>
php_write_logo_picture2.php
<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<?
if(trim($_FILES["fileUpload"]["tmp_name"]) != "")
{
$myImage = imagecreatefromjpeg($_FILES["fileUpload"]["tmp_name"]);
$myCopyright = imagecreatefromgif('logo.gif');
copy($_FILES["fileUpload"]["tmp_name"],"MyResize/".$_FILES["fileUpload"]["name"]);
$destWidth = imagesx($myImage);
$destHeight = imagesy($myImage);
$srcWidth = imagesx($myCopyright);
$srcHeight = imagesy($myCopyright);
$destX = ($destWidth - $srcWidth) / 2;
$destY = ($destHeight - $srcHeight) / 1;
$white = imagecolorexact($myCopyright, 255, 255, 255);
imagecolortransparent($myCopyright, $white);
imagecopymerge($myImage, $myCopyright, $destX, $destY, 0, 0, $srcWidth, $srcHeight, 50);
imagedestroy($myImage);
imagedestroy($myCopyright);
}
?>
<b>Original</b><br>
<img src="<?="MyResize/".$_FILES["fileUpload"]["name"];?>">
<hr>
<b>New Images</b><br>
<img src="<?="MyResize/image.png";?>">
</body>
</html>
Create a php file and save to path root-path/myphp/
Run
http://localhost/myphp/php_write_logo_picture1.php
Screenshot



