dynamic-text-image-generator-bta

Gesponsorde koppelingen

PHP script bestanden

  1. dynamic-text-image-generator-bta

« Lees de omschrijving en reacties

##### picgen.php #####

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<html>

<head>
<title>1M4G3 CR34T0R</title>
</head>

<body>

<style type="text/css">
.dashed { border-style:dashed;
border-color:#0000FF; }
.fonts { font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:12px; }
</style>

    <?
    if($_POST['createimg'])
    {

    ?>

        <div align="center">
        <img src="pic.php?text=<?= $_POST['imgtext']; ?>&font=<?= $_POST['imgfonttype']; ?>&fontsize=<?= $_POST['imgfontsize']; ?>&fontcolor=<?= $_POST['imgfontcolor']; ?>&bgcolor=<?= $_POST['imgbgcolor']; ?>">
        </div>
    <?
    }
    else
    {
    ?>

        <table width="250" cellpadding="0" border="1" cellspacing="0" class="dashed">
        <tr><td valign="top" bgcolor="#000000">
        <center>
        <font face="Verdana, Arial, Helvetica, sans-serif" color="#FFFFFF">
        <form method="post" action="<?= $_SERVER['PHP_SELF']; ?>">
        1M4G3 T3XT :<br />
        <input type="text" name="imgtext" value="1M4G3 T3XT" class="fonts" /><br />
        F0NT :<br />
        <select name="imgfonttype" class="fonts">
        <option value="5cent">5 cent</option>
        <option value="airone">Airstrip One</option>
        <option value="arial">Arial</option>
        <option value="comic">Comic Sans MS</option>
        <option value="cour">Courier New</option>
        <option value="georgia">Georgia</option>
        <option value="impact">Impact</option>
        <option value="lastninja">Last Ninja</option>
        <option value="verdana">Verdana</option>
        <option value="xbox">Xbox</option>
        </select><br />
        F0NTS1Z3 :<br />
        <select name="imgfontsize" class="fonts">
        <option value="16">16 px</option>
        <option value="32">32 px</option>
        <option value="48">48 px</option>
        <option value="64">64 px</option>
        </select><br />
        F0NTC0L0R :<br />
        <select name="imgfontcolor" class="fonts">
        <option value="red">Red</option>
        <option value="blue">Blue</option>
        <option value="green">Green</option>
        <option value="yellow">Yellow</option>
        <option value="orange">Orange</option>
        <option value="pink">Pink</option>
        <option value="lblue">Light Blue</option>
        <option value="grey">Grey</option>
        <option value="black">Black</option>
        <option value="white">White</option>
        </select><br />
        B4CKGR0UNDC0L0R :<br />
        <select name="imgbgcolor" class="fonts">
        <option value="red">Red</option>
        <option value="blue">Blue</option>
        <option value="green">Green</option>
        <option value="yellow">Yellow</option>
        <option value="orange">Orange</option>
        <option value="pink">Pink</option>
        <option value="lblue">Light Blue</option>
        <option value="grey">Grey</option>
        <option value="black">Black</option>
        <option value="white">White</option>
        </select><br /><br />
        <input type="submit" name="createimg" value="CR34T3!!!" class="fonts" />
        </form>
        </font>
        </center>
        </td></tr>
        </table>
    <?
    }
    ?>


</body>

</html>



##### pic.php #####
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?
    // Send png image header
    header("Content-Type: image/png");
    
    // Declare some vars
    $text = $_GET['text'];
    $tmp_font = $_GET['font'];
    $fontsize = $_GET['fontsize'];
    $tmp_fontcolor = $_GET['fontcolor'];
    $tmp_bgcolor = $_GET['bgcolor'];
    
    // Set font
    switch($tmp_font)
    {
        case
"5cent":
            $font = "fonts/5cent.ttf";
        break;
        case
"airone":
            $font = "fonts/airone.ttf";
        break;
        case
"arial":
            $font = "fonts/arial.ttf";
        break;
        case
"comic":
            $font = "fonts/comic.ttf";
        break;
        case
"cour":
            $font = "fonts/cour.ttf";
        break;
        case
"georgia":
            $font = "fonts/georgia.ttf";
        break;
        case
"impact":
            $font = "fonts/impact.ttf";
        break;
        case
"lastninja":
            $font = "fonts/lastninja.ttf";
        break;
        case
"verdana":
            $font = "fonts/verdana.ttf";
        break;
        case
"xbox":
            $font = "fonts/xbox.ttf";
        break;
    }

    
    // Calc the text size
    $box = ImageTTFbbox($fontsize, 0, $font, $text);
    
    // Calc some props for the image
    $width = $box[2] - $box[0];
    $height = $box[1] - $box[7];
    // 10 px empty space on each side
    $imagewidth = $width + 30;
    $imageheight = $height + 20;
        
    // Create the image
    $pic = ImageCreate($imagewidth, $imageheight);
    
    // Set the colors
    // Backgroundcolor

    switch($tmp_bgcolor)
    {
        case
"red":
            $bgcolor = ImageColorAllocate($pic, 255, 0, 0);
        break;
        case
"blue":
            $bgcolor = ImageColorAllocate($pic, 0, 0, 255);
        break;
        case
"green":
            $bgcolor = ImageColorAllocate($pic, 0, 255, 0);
        break;
        case
"yellow":
            $bgcolor = ImageColorAllocate($pic, 255, 255, 0);
        break;
        case
"orange":
            $bgcolor = ImageColorAllocate($pic, 236, 116, 10);
        break;
        case
"pink":
            $bgcolor = ImageColorAllocate($pic, 255, 128, 255);
        break;
        case
"lblue":
            $bgcolor = ImageColorAllocate($pic, 0, 255, 255);
        break;
        case
"grey":
            $bgcolor = ImageColorAllocate($pic, 192, 192, 192);
        break;
        case
"black":
            $bgcolor = ImageColorAllocate($pic, 0, 0, 0);
        break;
        case
"white":
            $bgcolor = ImageColorAllocate($pic, 255, 255, 255);
        break;
    }

    
    // Fontcolor
    switch($tmp_fontcolor)
    {
        case
"red":
            $fontcolor = ImageColorAllocate($pic, 255, 0, 0);
        break;
        case
"blue":
            $fontcolor = ImageColorAllocate($pic, 0, 0, 255);
        break;
        case
"green":
            $fontcolor = ImageColorAllocate($pic, 0, 255, 0);
        break;
        case
"yellow":
            $fontcolor = ImageColorAllocate($pic, 255, 255, 0);
        break;
        case
"orange":
            $fontcolor = ImageColorAllocate($pic, 236, 116, 10);
        break;
        case
"pink":
            $fontcolor = ImageColorAllocate($pic, 255, 128, 255);
        break;
        case
"lblue":
            $fontcolor = ImageColorAllocate($pic, 0, 255, 255);
        break;
        case
"grey":
            $fontcolor = ImageColorAllocate($pic, 192, 192, 192);
        break;
        case
"black":
            $fontcolor = ImageColorAllocate($pic, 0, 0, 0);
        break;
        case
"white":
            $fontcolor = ImageColorAllocate($pic, 255, 255, 255);
        break;
    }

    
    // Set the fontstart positions
    $xstart = 10;
    $ystart = $imageheight - 10;
    
    // Write the text
    ImageTTFText($pic, $fontsize, 0, $xstart, $ystart, $fontcolor, $font, $text);
    
    // Finish image
    ImagePng($pic);
    
    // Clean up memory
    ImageDestroy($pic);
?>

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.