Imagemagick与PHP
Fatal error: Uncaught exception 'ImagickDrawException' with message 'The given font is not found in the ImageMagick configuration and the file (/var/www/Arial) is not accessible' in /var/www/captcha.php:20 Stack trace:
0 /var/www/captcha.php(20): ImagickDraw->setfont('Arial') #1
{main} thrown in /var/www/captcha.php on line 20
I am getting the following errors when i try the following
<?php
/* Create Imagick object */
$Imagick = new Imagick();
/* Set font and font size. You can also specify /path/to/font.ttf */
$ImagickDraw->setFont( 'Helvetica Regular' );
?>
致命错误:未捕获异常 'ImagickDrawException',消息 '给定的字体是 没有在 ImageMagick配置中找到,文件 (/ var / www / Arial)无法访问' /var/www/captcha.php:20堆栈跟踪: p> 0 /var/www/captcha.php(20):在/ var / www / captcha中抛出的ImagickDraw-&gt; setfont('Arial')#1 h1>
{main}。 php 第20行 p> blockquote>
当我尝试以下 p>
&lt;时,我收到以下错误 ?php / *创建Imagick对象* / $ Imagick = new Imagick(); / *设置字体和字体大小。 你也可以指定/path/to/font.ttf * / $ ImagickDraw-&gt; setFont('Helvetica Regular'); ?&gt; code> pre> DIV>
You need to pass a filename to setFont()
, not a font name. E.g:
ImagickDraw->setFont('fonts/arial.ttf');
See the comment on the PHP manual page. Apparently this function only accepts filenames relative to the site root. It does not accept font names like Imagick::setFont()
does.