Learning & Integrating web technology and code help directory

How to use PHP & Write Logo/CopyRight to image (Watermark)

No comments
How to use PHP & Write Logo/CopyRight to image (Watermark) The guideline/example scripts how to using PHP and GD , Write Logo/CopyRight to image (Watermark)
Example
php_write_logo1.php
  1. <?php  
  2. echo "<img src=MyResize/image.png>";  
  3. $filname = "logo.gif";  
  4. $src = ImageCreateFromGif($filname);  
  5. $size = GetImageSize($filname);  
  6. $im = ImageCreate(500, 450);  
  7.   
  8. $bg = ImageColorAllocate($im, 255, 255, 0);  
  9. $color = ImageColorAllocate($im, 0, 0, 0);  
  10.   
  11. ImageCopy($im$src, 140, 170, 0, 0, $size[0], $size[1]);  
  12.   
  13. ImagePng($im,"MyResize/image.png");  
  14. ImageDestroy($src);  
  15. ImageDestroy($im);  
  16. ?>  
Create a php file and save to path root-path/myphp/
Screenshot
PHP & Write Logo/CopyRight to image (Watermark)
php_write_logo2.php
  1. <?php  
  2. echo "<img src=MyResize/image.png>";  
  3. $myImage = imagecreatefromjpeg('mygirl.jpg');  
  4. $myCopyright = imagecreatefromgif('logo.gif');  
  5.   
  6. $destWidth = imagesx($myImage);  
  7. $destHeight = imagesy($myImage);  
  8. $srcWidth = imagesx($myCopyright);  
  9. $srcHeight = imagesy($myCopyright);  
  10.   
  11. $destX = ($destWidth - $srcWidth) / 2;  
  12. $destY = ($destHeight - $srcHeight) / 1;  
  13. $white = imagecolorexact($myCopyright, 255, 255, 255);  
  14. imagecolortransparent($myCopyright$white);  
  15.   
  16. imagecopymerge($myImage$myCopyright$destX$destY, 0, 0, $srcWidth$srcHeight, 50);  
  17.   
  18. imagejpeg($myImage,"MyResize/image.png");  
  19. imagedestroy($myImage);  
  20. imagedestroy($myCopyright);  
  21. ?>  
Create a php file and save to path root-path/myphp/
Screenshot
PHP & Write Logo/CopyRight to image (Watermark)

No comments :

Post a Comment