watermark.php
<?php
$font = 'arial.ttf';
if($ext=="jpg" || $ext=="jpe") $im=@imagecreatefromjpeg("$imgfile");
elseif ($ext=="gif") $im=@imagecreatefromgif("$imgfile");
if (!$im) { /* See if it failed */
$im = ImageCreate (150, 30); /* Create a blank image */
$bgc = ImageColorAllocate ($im, 255, 255, 255);
$tc = ImageColorAllocate ($im, 0, 0, 0);
ImageFilledRectangle ($im, 0, 0, 150, 30, $bgc);
/* Output an errmsg */
ImageString($im, 1, 5, 5, "Error loading $imgfile", $tc);
return $im;
}
$x=imagesx($im);
$y=imagesy($im);
$fontsize=$x/16;
$fontsize=floor($fontsize); if($fontsize<10) $fontsize=10;
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
imagettftext($im, $fontsize, 0, 12, $fontsize+8, $black, $font, $text);
imagettftext($im, $fontsize, 0, 10, $fontsize+6, $white, $font, $text);
imagettftext($im, 10, 0, 10, $y-7, $black, $font, "copyright by KTOS");
imagettftext($im, 10, 0, 12, $y-8, $white, $font, "copyright by KTOS");
if($ext=="gif")
{
header("Content-type: image/gif"); imageGIF($im);
}
else
{
header("Content-type: image/jpeg"); imagejpeg($im);
}
imagedetroy($im);
?>
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.
Ten post edytował miedzna 14.02.2006, 14:04:57