.htaccess
RewriteEngine On
RewriteBase /
RewriteRule ^папка_относительный путь/(.+).jpeg$ inc/block/wmark.php?src=/папка_относительный путь/$1.jpeg
wmark.php
<?php
class watermark
{
function create_watermark( $main_img_obj, $text, $font, $r = 255, $g = 255, $b = 255, $alpha_level = 120 )
{
$width = imagesx($main_img_obj);
$height = imagesy($main_img_obj);
$angle = -rad2deg(atan2((-$height),($width)));
$text = " ".$text." ";
$c = imagecolorallocatealpha($main_img_obj, $r, $g, $b, $alpha_level);
$shadow = imagecolorallocatealpha($main_img_obj, 0, 0, 0, $alpha_level);
$size = (($width+$height)/2)*2/strlen($text);
$box = imagettfbbox ( $size, $angle, $font, $text );
$x = $width/2 - abs($box[4] - $box[0])/2;
$y = $height/2 + abs($box[5] - $box[1])/2;
imagettftext($main_img_obj,$size ,$angle, $x+2, $y+1, $shadow, $font, $text);
imagettftext($main_img_obj,$size ,$angle, $x, $y, $c, $font, $text);
return $main_img_obj;
}
}
header("Content-type: image/jpeg");
$watermark = new watermark();
$img = imagecreatefromjpeg($_SERVER['DOCUMENT_ROOT'].$_GET['src']);
$im=$watermark->create_watermark($img," ваш_сайт.ru ",$_SERVER['DOCUMENT_ROOT'].'/inc/block/geo.ttf',255,255,255,112);
imagejpeg($im,NULL,75);
imagedestroy($img);
imagedestroy($im);
?>
файл с шрифтом geo.ttf
geo.ttf