tekst-naar-image
---- createimage.php ----
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?
if ($_POST['submit'] && $_POST['txt'])
{
echo "<p>Converted image:</p>";
echo "<img src=\"convert.php?txt=" . $_POST['txt'] . "\">";
}
else
{
echo "<p><b>Convert image:</b></p>";
echo "<form method=\"post\" action=\"" . $_SERVER['PHP_SELF'] . "\">";
echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
echo "<tr><td>";
echo "<input type=\"text\" name=\"txt\">";
echo "</td>";
echo "<td>";
echo "<input type=\"submit\" name=\"submit\" value=\"convert image\">";
echo "</td></tr>";
echo "</table>";
echo "</form>";
}
?>
if ($_POST['submit'] && $_POST['txt'])
{
echo "<p>Converted image:</p>";
echo "<img src=\"convert.php?txt=" . $_POST['txt'] . "\">";
}
else
{
echo "<p><b>Convert image:</b></p>";
echo "<form method=\"post\" action=\"" . $_SERVER['PHP_SELF'] . "\">";
echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
echo "<tr><td>";
echo "<input type=\"text\" name=\"txt\">";
echo "</td>";
echo "<td>";
echo "<input type=\"submit\" name=\"submit\" value=\"convert image\">";
echo "</td></tr>";
echo "</table>";
echo "</form>";
}
?>
---- convert.php ----
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?
//-- width & height of img
$width = strlen($_GET['txt']) * 7;
$height = 15;
//-- create img
$txtimg = imagecreate($width, $height);
//-- set fontcolor & bgcolor
imagecolorallocate($txtimg, 215, 215, 215);
$txtcolor = imagecolorallocate($txtimg, 0,0,0);
//-- insert text
imagestring($txtimg, 3, 0, 0, $_GET['txt'], $txtcolor);
//-- send header information
header("Content-Type: image/png");
//-- show img
imagepng($txtimg);
//-- destroy img
imagedestroy($txtimg);
?>
//-- width & height of img
$width = strlen($_GET['txt']) * 7;
$height = 15;
//-- create img
$txtimg = imagecreate($width, $height);
//-- set fontcolor & bgcolor
imagecolorallocate($txtimg, 215, 215, 215);
$txtcolor = imagecolorallocate($txtimg, 0,0,0);
//-- insert text
imagestring($txtimg, 3, 0, 0, $_GET['txt'], $txtcolor);
//-- send header information
header("Content-Type: image/png");
//-- show img
imagepng($txtimg);
//-- destroy img
imagedestroy($txtimg);
?>