Holas gente wenna...aca tengo algunas pequenas lineas de PHP para agregar algun texto o copy right a un lote de imagenes. Espero q sea de su utilidad ;)
Las imagenes tienen q estar dentro d la carpeta donde se encuentra al archivo PHP.
<?
header('Content-type: image/jpeg');
$dir = getcwd();
$me = $_SERVER['SCRIPT_NAME'];
$me = basename($me);
$path=opendir($dir);
if ($path)
{
while($name_file = readdir($path))
{
if ((is_file($name_file)) && ($name_file != $me)&&($name_file!='.')&&($name_file!='..'))
{
$files[] = $name_file;
}
}
}
$n = count($files);
$text='©
[email protected]';//text of copy right
for($i=0;$i<$n;$i++)
{
$image=$files[$i];
$savein="img/".$files[$i];
$tmp=tempnam("tmp/","tmp");
addCopyRight($image, $text, $tmp, 100);
// save the image
$fp=fopen($savein,"w");
fputs($fp,fread(fopen($tmp,"r"),filesize($tmp)));
fclose($fp);
}
function addCopyRight($myImage, $text, $imageWithCopyRight, $quality)
{
// details of image
$details= getimagesize($myImage);
$width = $details[0];
$height = $details[1];
// create the image
$img = ImageCreateFromJPEG($myImage);
//color of text copy right
$colorText=imagecolorallocate($img, 13, 149, 83);
//font of text
$font = 'arial.ttf';
imagettftext($img, 60, -90, $width-160,20, $colorText, $font, $text);//vertical
//imagettftext($img, 150, 50, 0.03*$width, $height-50, $colorText, $font, $text);//Diagonal
//imagettftext($img, 80, 0, 0.08*$width, $height-50, $colorText, $font, $text);//Horizontal
/*asignar valore de acuerdo a las dimensiones de las imagenes.*/
/*este ejemplo esta echo para imagenes 3264 X 2448 px*/
// save the image
ImageJPEG($img, $imageWithCopyRight, $quality);
// close the images
ImageDestroy($img);
}
?>