I have installed the imagick component in the virtual machine, as well as the fonts to be used.
As shown in the picture:
Imagick drawing part code is as follows:
<code> $imagick = new Imagick($template_image); $draw = new ImagickDraw(); $draw->setFillColor('black'); $draw->setFont('/usr/share/fonts/wqy-microhei.ttc'); $draw->settextencoding('utf-8'); $draw->setFontSize(30); imagick_add_text($imagick,$draw,"测试", 302, 688, 130,'#33BAF6');</code>
Writing function:
<code>function imagick_add_text(&$imagick, &$draw, $text, $x = 0, $y = 0, $font_size = 12, $fill_color = 0, $text_kerning = 0) { if (isset($font_size)) $draw->setFontSize($font_size); if (isset($fill_color)) $draw->setFillColor($fill_color); if (isset($text_kerning)) $draw->setTextKerning($text_kerning); $imagick->annotateImage($draw, $x, $y, 0, $text); }</code>
The problem now is that there is no error in the $draw->setFont()
step, indicating that the font setting is successful, but $imagick->annotateImage()
that is, there is an error in the drawing step.
Why, is it a font problem?
Note:
1. I use the vagrant virtual environment for development.
2. The same font is installed in the test environment, and Imagick can be used to draw and write successfully. (The test environment fonts are installed by operation and maintenance personnel)
I have installed the imagick component in the virtual machine, as well as the fonts to be used.
As shown in the picture:
Imagick drawing part code is as follows:
<code> $imagick = new Imagick($template_image); $draw = new ImagickDraw(); $draw->setFillColor('black'); $draw->setFont('/usr/share/fonts/wqy-microhei.ttc'); $draw->settextencoding('utf-8'); $draw->setFontSize(30); imagick_add_text($imagick,$draw,"测试", 302, 688, 130,'#33BAF6');</code>
Writing function:
<code>function imagick_add_text(&$imagick, &$draw, $text, $x = 0, $y = 0, $font_size = 12, $fill_color = 0, $text_kerning = 0) { if (isset($font_size)) $draw->setFontSize($font_size); if (isset($fill_color)) $draw->setFillColor($fill_color); if (isset($text_kerning)) $draw->setTextKerning($text_kerning); $imagick->annotateImage($draw, $x, $y, 0, $text); }</code>
The problem now is that there is no error in the $draw->setFont()
step, indicating that the font setting is successful, but $imagick->annotateImage()
that is, there is an error in the drawing step.
Why, is it a font problem?
Note:
1. I use the vagrant virtual environment for development.
2. The same font is installed in the test environment, and Imagick can be used to draw and write successfully. (The test environment fonts are installed by operation and maintenance personnel)