$image = new 'Imagick();
$draw = new 'ImagickDraw();
$fillColor = new 'ImagickPixel('black');
$bgColor = new 'ImagickPixel('gray');
$fontSize = 24;
$text = 'helloworld';
$text = substr($text, 0, rand(1, 10));
$font = '/home/koogua/font/yy.ttf';
$draw->setFont($font);
$draw->setFontSize($fontSize);
$draw->setFillColor($fillColor);
$draw->setStrokeAntialias(true);
$draw->setTextAntialias(true);
$draw->setgravity('Imagick::GRAVITY_CENTER);
$draw->annotation(0, 0, $text);
$metrics = $image->queryFontMetrics($draw, $text);
$image->newImage($metrics['textWidth'] + 30, $metrics['textHeight'] + 10, $bgColor);
$image->setImageFormat('png');
$image->drawImage($draw);
$draw->destroy();
// $image->writeImage('test.png');
header('Content-Type: image/png');
echo $image->getImageBlob();
exit;
// $this->response->setContentType( 'image/png');
// $this->response->setContent($image->getImageBlob());
// $this->response->send();
环境:phalcon
输出字体:刷新页面1- 5次,capcha图像正常,5次后,apache"死机"
不带字体的输出:ok
保存文件:ok
当我将字体大小设置为18时,一切正常,其他字体大小将导致apache"死",似乎18是唯一的幸运数字,很奇怪,是吗?
环境:另一个PHP框架(启用重写)
输出字体:ok
不带字体的输出:ok
保存文件:ok
环境:纯php
输出字体:ok
不带字体的输出:ok
保存文件:ok
谁能测试一下上面的代码?
字体文件好像有问题,换一种常用的字体,现在一切都好了