質問編集履歴
3
不要な部分を削除しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -66,12 +66,6 @@
|
|
66
66
|
|
67
67
|
|
68
68
|
|
69
|
-
//文字列の幅を取得 => よくわからない
|
70
|
-
|
71
|
-
$metrics = $templateImg->queryFontMetrics($draw, $string);
|
72
|
-
|
73
|
-
|
74
|
-
|
75
69
|
//文字色$pixel = new ImagickPixel();
|
76
70
|
|
77
71
|
$pixel->setColor('#abcdef');
|
2
質問でのコードの書き方が間違っていたため修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -32,11 +32,7 @@
|
|
32
32
|
|
33
33
|
ユーザーネームの文字列を山なりにしたいです。
|
34
34
|
|
35
|
-
|
35
|
+
```php
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
36
|
|
41
37
|
//本来はディレクトリなどから指定する
|
42
38
|
|
@@ -103,3 +99,5 @@
|
|
103
99
|
//終
|
104
100
|
|
105
101
|
$templateImg->destroy();
|
102
|
+
|
103
|
+
```
|
1
ソースの追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -31,3 +31,75 @@
|
|
31
31
|
のイメー自画像にある「Image Magick」のような感じに
|
32
32
|
|
33
33
|
ユーザーネームの文字列を山なりにしたいです。
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
//本来はディレクトリなどから指定する
|
42
|
+
|
43
|
+
$src = 'test.png';
|
44
|
+
|
45
|
+
$dst = 'aft_test.png';
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
//画像の読み込み
|
50
|
+
|
51
|
+
$templateImg = new Imagick($src);
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
//文字列を書き込んでくれるクラス
|
56
|
+
|
57
|
+
$draw = new ImagickDraw();
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
//表示する文字列
|
62
|
+
|
63
|
+
$string = 'This is TEST!';
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
//フォントサイズ
|
68
|
+
|
69
|
+
$draw->setFontSize(24);
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
//文字列の幅を取得 => よくわからない
|
74
|
+
|
75
|
+
$metrics = $templateImg->queryFontMetrics($draw, $string);
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
//文字色$pixel = new ImagickPixel();
|
80
|
+
|
81
|
+
$pixel->setColor('#abcdef');
|
82
|
+
|
83
|
+
$draw->setFillColor($pixel);
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
//上部、左右の中心に文字
|
88
|
+
|
89
|
+
$draw->setGravity(imagick::GRAVITY_NORTH);
|
90
|
+
|
91
|
+
$draw->annotation(0, 0, $string);
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
//画像へ文字列を合成
|
96
|
+
|
97
|
+
$templateImg->drawImage($draw);
|
98
|
+
|
99
|
+
//ファイルとして出力
|
100
|
+
|
101
|
+
$templateImg->writeImage($dst);
|
102
|
+
|
103
|
+
//終
|
104
|
+
|
105
|
+
$templateImg->destroy();
|