watermark.php
  1. <?php
  2. $font = 'arial.ttf';
  3. $ext=substr($imgfile,-3);
  4. $ext=strtolower($ext);
  5.  
  6. if($ext=="jpg" || $ext=="jpe") $im=@imagecreatefromjpeg("$imgfile");
  7. elseif ($ext=="gif") $im=@imagecreatefromgif("$imgfile"); 
  8. else {print "Unknown image format"; exit;}
  9.  
  10.  if (!$im) { /* See if it failed */
  11.        $im = ImageCreate (150, 30); /* Create a blank image */
  12.        $bgc = ImageColorAllocate ($im, 255, 255, 255);
  13.        $tc  = ImageColorAllocate ($im, 0, 0, 0);
  14.        ImageFilledRectangle ($im, 0, 0, 150, 30, $bgc); 
  15.        /* Output an errmsg */
  16.        ImageString($im, 1, 5, 5, "Error loading $imgfile", $tc); 
  17.     return $im;
  18.    }
  19.  
  20. $x=imagesx($im);
  21. $y=imagesy($im);
  22. $fontsize=$x/16;
  23. $fontsize=floor($fontsize);
  24. if($fontsize<10) $fontsize=10;
  25.  
  26. $white = imagecolorallocate($im, 255, 255, 255);
  27. $black = imagecolorallocate($im, 0, 0, 0);
  28.  
  29. imagettftext($im, $fontsize, 0, 12, $fontsize+8, $black, $font, $text);
  30. imagettftext($im, $fontsize, 0, 10, $fontsize+6, $white, $font, $text);
  31.  
  32.  
  33. imagettftext($im, 10, 0, 10, $y-7, $black, $font, "copyright by KTOS");
  34. imagettftext($im, 10, 0, 12, $y-8, $white, $font, "copyright by KTOS");
  35.  
  36. if($ext=="gif") 
  37.     {
  38.     header("Content-type: image/gif");
  39.     imageGIF($im);
  40.     }
  41. else
  42.     {
  43.     header("Content-type: image/jpeg");
  44.     imagejpeg($im);
  45.  
  46.     }
  47. imagedetroy($im);
  48. ?>


i wywolujemy:
<img src="watermark.php?text=JAKIŚTEXT" border=0>

wszystko ładnie, tylko chcę żeby ten górny napis pojawiał się trochę niżej, gdzieś tu można zmienić, ale nie wiem gdzie?

Dzięki za pomoc.