質問編集履歴
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -16,35 +16,43 @@
|
|
16
16
|
|
17
17
|
```ここに言語を入力
|
18
18
|
|
19
|
+
現在のコードです
|
20
|
+
|
21
|
+
背景の赤色を透明にしたいです
|
22
|
+
|
19
23
|
|
20
24
|
|
21
25
|
<?php
|
22
26
|
|
23
|
-
|
27
|
+
$im = imagecreate(150,50);
|
24
28
|
|
25
|
-
$
|
29
|
+
$str="aaaaa";
|
26
30
|
|
27
|
-
$
|
31
|
+
$bg = imagecolorallocate($im, 255,0,0);
|
28
32
|
|
29
|
-
$
|
33
|
+
$mid = imagecolorallocate($im, 255,255,255);
|
30
34
|
|
35
|
+
$fw = imagefontwidth(5);
|
31
36
|
|
37
|
+
$l = strlen($str);
|
32
38
|
|
33
|
-
|
39
|
+
$tw = $l * $fw;
|
34
40
|
|
35
|
-
image
|
41
|
+
$iw = imagesx($im);
|
36
42
|
|
43
|
+
$hiw = imagesy($im);
|
37
44
|
|
45
|
+
$hw = imagefontheight(5);
|
38
46
|
|
39
|
-
/
|
47
|
+
$xpos = ($iw - $tw)/2;
|
40
48
|
|
41
|
-
|
49
|
+
$ypos = ($hiw-$hw)/2;
|
42
50
|
|
51
|
+
imagestring ($im, 5, $xpos, $ypos, $str, $mid);
|
43
52
|
|
53
|
+
header("content-type: image/png");
|
44
54
|
|
45
|
-
|
55
|
+
imagepng($im);
|
46
|
-
|
47
|
-
imagepng($im, './imagecolortransparent.png');
|
48
56
|
|
49
57
|
imagedestroy($im);
|
50
58
|
|