Answer the question
In order to leave comments, you need to log in
Text over image?
There is a script that text on top of the image.
The text that a person enters on the index.php page
<div class="rtext2">Enter you names:</div>
<form method="POST" action="load.php?id=<? echo $id;?>" style="padding-top: 5px;">
<input type="text" name="name" placeholder="Ex. your names" style="width: 310px; height: 51px; font-size: 18px; padding-left: 8px; border: 4px solid #77B200;">
<input type="submit" style="height: 70px; width: 250px; font-size: 15px; border: none; margin-top: 15px; background: -3px -3px url ' input type="submit" class="button_find" value=Afla! ' no-repeat;" value="">
</form>
<?php
function writeTextOnImage($filename, $text)
{
$size_img = getimagesize($filename);
if ($size_img[2]==2) $src_img = imagecreatefromjpeg($filename);
else if ($size_img[2]==1) $src_img = imagecreatefromgif($filename);
else if ($size_img[2]==3) $src_img = imagecreatefrompng($filename);
// устанавливаем цвет нашей надписи и прозрачность (тут он будет синий и полностью прозрачный)
$color = imagecolorallocatealpha($src_img, 255, 128, 64, 0);
$font_file = "font.ttf"; // шрифт, которым пишем надпись (будьте внимательны с путем к шрифту)
$img_x = imagesx($src_img);
$img_y = imagesy($src_img);
$height_font = 30; // размер шрифта
$angle = 0; // наклон надписи
$iddmg = $_GET['idd'];
// Запись текста поверх изображения
$box = imagettftext($src_img, $height_font, $angle, $img_x - 655, $img_y - 285, $color, $font_file, $text);
// Вывод изображения в браузер
if ($size_img[2]==2)
{
header ("Content-type: image/jpeg");
imagejpeg($src_img, 'images/'.$iddmg.'.jpg');
imagejpeg($src_img);
}
else if ($size_img[2]==1)
{
header ("Content-type: image/gif");
imagegif($src_img);
}
else if ($size_img[2]==3)
{
header ("Content-type: image/png");
imagepng($src_img);
imagejpeg($src_img, 'images/'.$iddmg.'.png');
}
return true;
}
// использование
$name = $_GET['name'];
$ran_dom = rand (1 , 10);
$img = "img/".$ran_dom.".png"; // путь к изображению
writeTextOnImage($img, "$name");
Answer the question
In order to leave comments, you need to log in
In somehow in a mess it is written. And it's not clear - if the writeTextOnImage function works - what's the point of placing it here? Those. I mean - you need to write immediately closer to the point.
All I understood from this is that you will have 2 forms. What for? Two inputs won't work?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question