Learning & Integrating web technology and code help directory

How to use PHP & Upload and Write Logo to image (Watermark)

No comments
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)
Example
php_write_logo_picture1.php
  1. <html>  
  2. <head>  
  3. <title>ShotDev.Com Tutorial</title>  
  4. </head>  
  5. <body>  
  6. <form action="php_write_logo_picture2.php" method="post" enctype="multipart/form-data" name="frmMain">  
  7. <table width="343" border="1">  
  8. <tr>  
  9. <td>Upload</td>  
  10. <td><input name="fileUpload" type="file"></td>  
  11. </tr>  
  12. <tr>  
  13. <td>&nbsp;</td>  
  14. <td><input type="submit" name="Submit" value="Submit"></td>  
  15. </tr>  
  16. </table>  
  17. </form>  
  18. </body>  
  19. </html>  
php_write_logo_picture2.php
  1. <html>  
  2. <head>  
  3. <title>ShotDev.Com Tutorial</title>  
  4. </head>  
  5. <body>  
  6. <?  
  7. if(trim($_FILES["fileUpload"]["tmp_name"]) != "")  
  8. {  
  9. $myImage = imagecreatefromjpeg($_FILES["fileUpload"]["tmp_name"]);  
  10. $myCopyright = imagecreatefromgif('logo.gif');  
  11.   
  12. copy($_FILES["fileUpload"]["tmp_name"],"MyResize/".$_FILES["fileUpload"]["name"]);  
  13. $destWidth = imagesx($myImage);  
  14. $destHeight = imagesy($myImage);  
  15. $srcWidth = imagesx($myCopyright);  
  16. $srcHeight = imagesy($myCopyright);  
  17.   
  18. $destX = ($destWidth - $srcWidth) / 2;  
  19. $destY = ($destHeight - $srcHeight) / 1;  
  20. $white = imagecolorexact($myCopyright, 255, 255, 255);  
  21. imagecolortransparent($myCopyright$white);  
  22.   
  23. imagecopymerge($myImage$myCopyright$destX$destY, 0, 0, $srcWidth$srcHeight, 50);  
  24.   
  25. imagedestroy($myImage);  
  26. imagedestroy($myCopyright);  
  27. }  
  28. ?>  
  29. <b>Original</b><br>  
  30. <img src="<?="MyResize/".$_FILES["fileUpload"]["name"];?>">  
  31. <hr>  
  32. <b>New Images</b><br>  
  33. <img src="<?="MyResize/image.png";?>">  
  34. </body>  
  35. </html>  
Create a php file and save to path root-path/myphp/
Screenshot
PHP & Upload and Write Logo to image (Watermark)
PHP & Upload and Write Logo to image (Watermark)

No comments :

Post a Comment