如何在imagemagick中自动换行
我能够计算出像这样的基本自动换行功能
$draw = new ImagickDraw();
$x = 0;
$y=20;
$angle = 0;
$str = "some text for testing of a word wrap in imagemagick";
$str = wordwrap($str, 10,"\r");
$im->annotateImage( $draw, $x, $y, $angle, $str );
,并且似乎工作正常,除了跟踪我认为它称为“你知道行之间的空间太大,以及关于如何解决此问题的想法或想法,或者是否有更好的方法”选项
I was able to figure a basic word wrap function like this
$draw = new ImagickDraw();
$x = 0;
$y=20;
$angle = 0;
$str = "some text for testing of a word wrap in imagemagick";
$str = wordwrap($str, 10,"\r");
$im->annotateImage( $draw, $x, $y, $angle, $str );
and that seems to work ok except that the tracking i think its called you know the space between lines is too much and thoughts or ideas on how to fix this or if there is a better option
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
行高由字体规格决定。您当然可以添加一个空行,否则您需要一次渲染一行并手动指定图像中文本的偏移量。
[编辑]:根据OP请求,似乎有一个命令行版本。
The line height is determined by the font metric. You could of course add a blank line otherwise you would need to render one line at a time and manually specify the offset of the text within the image.
[EDIT] : On OP request, there appears to be a command-line version of it.
一些重构:
Some refactoring:
正弦我可以控制渲染每条线的间距
Sine I could control the spacing I went with rendering the lines each
您可以让 ImageMagic 为您计算指标详细信息: http://php.net /manual/en/function.imagick-queryfontmetrics.php。
You can have ImageMagic calculate the metrics details for you: http://php.net/manual/en/function.imagick-queryfontmetrics.php.