Exemplo n.º 1
0
 public function text($text, $color, $size, $font = 'FetteSteinschrift')
 {
     $font = BASE . "vendor/captcha/fonts/en/" . $font . ".ttf";
     $draw = new \ImagickDraw();
     $draw->setGravity(\Imagick::GRAVITY_CENTER);
     $draw->setFont($font);
     $draw->setFontSize($size);
     $draw->setFillColor(new \ImagickPixel($color));
     $im = new \imagick();
     $properties = $im->queryFontMetrics($draw, $text);
     $im->newImage(intval($properties['textWidth'] + 5), intval($properties['textHeight'] + 5), new \ImagickPixel('transparent'));
     $im->setImageFormat('png');
     $im->annotateImage($draw, 0, 0, 0, $text);
     return $im;
 }