当前位置: 首页>>代码示例>>PHP>>正文


PHP ImagickDraw::setFontSize方法代码示例

本文整理汇总了PHP中ImagickDraw::setFontSize方法的典型用法代码示例。如果您正苦于以下问题:PHP ImagickDraw::setFontSize方法的具体用法?PHP ImagickDraw::setFontSize怎么用?PHP ImagickDraw::setFontSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ImagickDraw的用法示例。


在下文中一共展示了ImagickDraw::setFontSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createEmailPic

function createEmailPic($jid, $email)
{
    $cachefile = DOCUMENT_ROOT . '/cache/' . $jid . '_email.png';
    if (file_exists(DOCUMENT_ROOT . '/cache/' . $jid . '_email.png')) {
        unlink(DOCUMENT_ROOT . '/cache/' . $jid . '_email.png');
    }
    $draw = new ImagickDraw();
    $draw->setFontSize(13);
    $draw->setGravity(Imagick::GRAVITY_CENTER);
    $canvas = new Imagick();
    $metrics = $canvas->queryFontMetrics($draw, $email);
    $canvas->newImage($metrics['textWidth'], $metrics['textHeight'], "transparent", "png");
    $canvas->annotateImage($draw, 0, 0, 0, $email);
    $canvas->setImageFormat('PNG');
    $canvas->writeImage($cachefile);
}
开发者ID:vincentux,项目名称:movim_ynh,代码行数:16,代码来源:UtilsPicture.php

示例2: renderImage

 public function renderImage()
 {
     //Create a ImagickDraw object to draw into.
     $draw = new \ImagickDraw();
     $darkColor = new \ImagickPixel('brown');
     //http://www.imagemagick.org/Usage/compose/#compose_terms
     $draw->setStrokeColor($darkColor);
     $draw->setFillColor('white');
     $draw->setStrokeWidth(2);
     $draw->setFontSize(72);
     $draw->setStrokeOpacity(1);
     $draw->setStrokeColor($darkColor);
     $draw->setStrokeWidth(2);
     $draw->setFont("../fonts/CANDY.TTF");
     $draw->setFontSize(140);
     $draw->setFillColor('none');
     $draw->rectangle(0, 0, 1000, 300);
     $draw->setFillColor('white');
     $draw->annotation(50, 180, "Lorem Ipsum!");
     $imagick = new \Imagick(realpath("images/TestImage.jpg"));
     $draw->composite(\Imagick::COMPOSITE_MULTIPLY, -500, -200, 2000, 600, $imagick);
     //Create an image object which the draw commands can be rendered into
     $imagick = new \Imagick();
     $imagick->newImage(1000, 300, "SteelBlue2");
     $imagick->setImageFormat("png");
     //Render the draw commands in the ImagickDraw object
     //into the image.
     $imagick->drawImage($draw);
     //Send the image to the browser
     header("Content-Type: image/png");
     echo $imagick->getImageBlob();
 }
开发者ID:finelinePG,项目名称:imagick,代码行数:32,代码来源:compositeText.php

示例3: calculateTextSize

 /**
  * Calculates size for bounding box of string written in given font.
  *
  * @param string        $string
  * @param FontInterface $font
  *
  * @return bool|Box Instance of Box object, false on error
  */
 public static function calculateTextSize($string, FontInterface $font)
 {
     $imagine = Tygh::$app['image'];
     if ($imagine instanceof \Imagine\Imagick\Imagine && class_exists('ImagickDraw')) {
         $text = new \ImagickDraw();
         $text->setFont($font->getFile());
         if (version_compare(phpversion("imagick"), "3.0.2", ">=")) {
             $text->setResolution(96, 96);
             $text->setFontSize($font->getSize());
         } else {
             $text->setFontSize((int) ($font->getSize() * (96 / 72)));
         }
         $imagick = new \Imagick();
         $info = $imagick->queryFontMetrics($text, $string);
         $text->clear();
         $text->destroy();
         $imagick->clear();
         $imagick->destroy();
         return new Box($info['textWidth'], $info['textHeight']);
     }
     if ($imagine instanceof \Imagine\Gd\Imagine && function_exists('imagettfbbox')) {
         $ttfbbox = imagettfbbox($font->getSize(), 0, $font->getFile(), $string);
         return new Box(abs($ttfbbox[2]), abs($ttfbbox[7]));
     }
     return false;
 }
开发者ID:ambient-lounge,项目名称:site,代码行数:34,代码来源:ImageHelper.php

示例4: __construct

 /**
  * Creates a new Label component.
  *
  * @param OsuSignature $signature The base signature
  * @param int $x The X position of this label
  * @param int $y The Y position of this label
  * @param string $text The text of this label
  * @param string $font The font to use for this label; can be a string or the constants defined in {@link ComponentLabel}
  * @param string $colour The colour of the text of the label
  * @param int $fontSize The size of the font of the label
  * @param int $textAlignment The text alignment
  * @param int $width Width of the label, set to -1 to use the text size, anything bigger can be used to spoof the component system. -2 makes the component sizeless
  * @param int $height Height of the label, set to -1 to use the text size, anything bigger can be used to spoof the component system
  */
 public function __construct(OsuSignature $signature, $x = 0, $y = 0, $text, $font = self::FONT_REGULAR, $colour = '#555555', $fontSize = 14, $textAlignment = Imagick::ALIGN_UNDEFINED, $width = -1, $height = -1)
 {
     parent::__construct($signature, $x, $y);
     $this->text = $text;
     $this->font = $font;
     $this->colour = $colour;
     $this->fontSize = $fontSize;
     $this->textAlignment = $textAlignment;
     $this->width = $width;
     $this->height = $height;
     $this->drawSettings = new ImagickDraw();
     $this->drawSettings->setFont(self::FONT_DIRECTORY . $font);
     $this->drawSettings->setFontSize($fontSize);
     $this->drawSettings->setTextAlignment($textAlignment);
     $this->drawSettings->setFillColor($colour);
     $this->usesSpace = $width != -2;
     if ($width <= -1 || $height <= -1) {
         $tempImg = new Imagick();
         $metrics = $tempImg->queryFontMetrics($this->drawSettings, $this->text);
         $this->width = $width <= -1 ? $metrics['textWidth'] : $width;
         // yeah i have to do some bullshit
         $this->actualWidth = $metrics['textWidth'];
         $this->height = $metrics['boundingBox']['y2'] - $this->y;
     }
 }
开发者ID:BTCTaras,项目名称:osusig,代码行数:39,代码来源:ComponentLabel.php

示例5: createImage

 private function createImage()
 {
     /* Create Imagick object */
     $this->Imagick = new \Imagick();
     /* Create the ImagickPixel object (used to set the background color on image) */
     $bg = new \ImagickPixel();
     /* Set the pixel color to white */
     $bg->setColor($this->bg_color);
     /* Create a drawing object and set the font size */
     $ImagickDraw = new \ImagickDraw();
     /* Set font and font size. You can also specify /path/to/font.ttf */
     if ($this->font) {
         $ImagickDraw->setFont($this->font);
     }
     $ImagickDraw->setFontSize($this->font_size);
     /* Create new empty image */
     $this->Imagick->newImage($this->image_width, $this->image_height, $bg);
     /* Write the text on the image */
     $this->Imagick->annotateImage($ImagickDraw, $this->text_position_left, $this->text_position_top, 0, $this->getCaptchaText());
     /* Add some swirl */
     $this->Imagick->swirlImage(20);
     /* Create a few random lines */
     $ImagickDraw->line(rand(0, $this->image_width), rand(0, $this->image_height), rand(0, $this->image_width), rand(0, $this->image_height));
     $ImagickDraw->line(rand(0, $this->image_width), rand(0, $this->image_height), rand(0, $this->image_width), rand(0, $this->image_height));
     $ImagickDraw->line(rand(0, $this->image_width), rand(0, $this->image_height), rand(0, $this->image_width), rand(0, $this->image_height));
     $ImagickDraw->line(rand(0, $this->image_width), rand(0, $this->image_height), rand(0, $this->image_width), rand(0, $this->image_height));
     $ImagickDraw->line(rand(0, $this->image_width), rand(0, $this->image_height), rand(0, $this->image_width), rand(0, $this->image_height));
     /* Draw the ImagickDraw object contents to the image. */
     $this->Imagick->drawImage($ImagickDraw);
     /* Give the image a format */
     $this->Imagick->setImageFormat($this->image_format);
 }
开发者ID:xepan,项目名称:base,代码行数:32,代码来源:Captcha.php

示例6: createAvatarAutomatically

 /**
  * アバター自動生成処理
  *
  * @param Model $model ビヘイビア呼び出し元モデル
  * @param array $user ユーザデータ配列
  * @return mixed On success Model::$data, false on failure
  * @throws InternalErrorException
  */
 public function createAvatarAutomatically(Model $model, $user)
 {
     //imagickdraw オブジェクトを作成します
     $draw = new ImagickDraw();
     //文字色のセット
     $draw->setfillcolor('white');
     //フォントサイズを 160 に設定します
     $draw->setFontSize(140);
     //テキストを追加します
     $draw->setFont(CakePlugin::path($model->plugin) . 'webroot' . DS . 'fonts' . DS . 'ipaexg.ttf');
     $draw->annotation(19, 143, mb_substr(mb_convert_kana($user['User']['handlename'], 'KVA'), 0, 1));
     //新しいキャンバスオブジェクトを作成する
     $canvas = new Imagick();
     //ランダムで背景色を指定する
     $red1 = strtolower(dechex(mt_rand(3, 12)));
     $red2 = strtolower(dechex(mt_rand(0, 15)));
     $green1 = strtolower(dechex(mt_rand(3, 12)));
     $green2 = strtolower(dechex(mt_rand(0, 15)));
     $blue1 = strtolower(dechex(mt_rand(3, 12)));
     $blue2 = strtolower(dechex(mt_rand(0, 15)));
     $canvas->newImage(179, 179, '#' . $red1 . $red2 . $green1 . $green2 . $blue1 . $blue2);
     //ImagickDraw をキャンバス上に描画します
     $canvas->drawImage($draw);
     //フォーマットを PNG に設定します
     $canvas->setImageFormat('png');
     App::uses('TemporaryFolder', 'Files.Utility');
     $folder = new TemporaryFolder();
     $filePath = $folder->path . DS . Security::hash($user['User']['handlename'], 'md5') . '.png';
     $canvas->writeImages($filePath, true);
     return $filePath;
 }
开发者ID:akagane99,项目名称:Users,代码行数:39,代码来源:AvatarBehavior.php

示例7: Imagick

 function page_testfonts()
 {
     //load background
     $im = new Imagick();
     $im->newimage(800, 10000, 'lightgray');
     $y = 10;
     $i = 1;
     foreach ($im->queryFonts() as $font) {
         $insert_image = new Imagick();
         $insert_image->newImage(600, 30, 'whitesmoke');
         $insert_image->setImageFormat("png");
         $draw = new ImagickDraw();
         $draw->setFont($font);
         $draw->setFontSize(25);
         $draw->setFillColor(new ImagickPixel('black'));
         $draw->setgravity(imagick::GRAVITY_NORTH);
         $insert_image->annotateImage($draw, 0, 0, 0, $i . '.' . $font);
         $im->compositeImage($insert_image, $insert_image->getImageCompose(), 100, $y);
         $y += 30;
         $i++;
     }
     $im->setImageFormat('jpg');
     header('Content-Type: image/jpg');
     echo $im;
 }
开发者ID:xepan,项目名称:commerce,代码行数:25,代码来源:fonts.php

示例8: writeText

 function writeText($text)
 {
     if ($this->printer == null) {
         throw new LogicException("Not attached to a printer.");
     }
     if ($text == null) {
         return;
     }
     $text = trim($text, "\n");
     /* Create Imagick objects */
     $image = new \Imagick();
     $draw = new \ImagickDraw();
     $color = new \ImagickPixel('#000000');
     $background = new \ImagickPixel('white');
     /* Create annotation */
     //$draw -> setFont('Arial');// (not necessary?)
     $draw->setFontSize(24);
     // Size 21 looks good for FONT B
     $draw->setFillColor($color);
     $draw->setStrokeAntialias(true);
     $draw->setTextAntialias(true);
     $metrics = $image->queryFontMetrics($draw, $text);
     $draw->annotation(0, $metrics['ascender'], $text);
     /* Create image & draw annotation on it */
     $image->newImage($metrics['textWidth'], $metrics['textHeight'], $background);
     $image->setImageFormat('png');
     $image->drawImage($draw);
     //$image -> writeImage("test.png");
     /* Save image */
     $escposImage = new EscposImage();
     $escposImage->readImageFromImagick($image);
     $size = Printer::IMG_DEFAULT;
     $this->printer->bitImage($escposImage, $size);
 }
开发者ID:jslemmer,项目名称:cafe,代码行数:34,代码来源:ImagePrintBuffer.php

示例9: makeImageOfCertification

 public function makeImageOfCertification()
 {
     date_default_timezone_set('UTC');
     $timeStamp = date('jS F Y');
     $text = "CERTIFIED COPY" . "\n" . $this->serial . "\n" . $timeStamp;
     $image = new \Imagick();
     $draw = new \ImagickDraw();
     $color = new \ImagickPixel('#000000');
     $background = new \ImagickPixel("rgb(85, 196, 241)");
     $draw->setFont($this->container->getParameter('assetic.write_to') . $this->container->get('templating.helper.assets')->getUrl('fonts/futura.ttf'));
     $draw->setFontSize(24);
     $draw->setFillColor($color);
     $draw->setTextAntialias(true);
     $draw->setStrokeAntialias(true);
     //Align text to the center of the background
     $draw->setTextAlignment(\Imagick::ALIGN_CENTER);
     //Get information of annotation image
     $metrics = $image->queryFontMetrics($draw, $text);
     //Calc the distance(pixels) to move the sentences
     $move = $metrics['textWidth'] / 2;
     $draw->annotation($move, $metrics['ascender'], $text);
     //Create an image of certification
     $image->newImage($metrics['textWidth'], $metrics['textHeight'], $background);
     $image->setImageFormat('png');
     $image->drawImage($draw);
     //Save an image temporary
     $image->writeImage("cert_" . $this->serial . "_.png");
 }
开发者ID:DanieleMenara,项目名称:CreateSafe,代码行数:28,代码来源:WaterMark.php

示例10: printText

 public function printText($canvas, $size, $angle, $x, $y, $color, $fontfile, $text, $opacity = 100)
 {
     $draw = new ImagickDraw();
     $draw->setFillColor(self::rgb($color));
     $draw->setFontSize($size * $this->fontSizeScale);
     $draw->setFont($fontfile);
     $draw->setFillOpacity($opacity / 100);
     $canvas->annotateImage($draw, $x, $y, $angle, $text);
 }
开发者ID:neilcrookes,项目名称:Ximi,代码行数:9,代码来源:ximi_image_imagick.php

示例11: test_annotation

function test_annotation(&$canvas)
{
    $draw = new ImagickDraw();
    $font = __DIR__ . '/php_imagick_tests/anonymous_pro_minus.ttf';
    $draw->setFont($font);
    $draw->setFontSize(40);
    $draw->annotation(50, 440, 'Yukkuri shiteitte ne!!!');
    $canvas->drawImage($draw);
}
开发者ID:badlamer,项目名称:hhvm,代码行数:9,代码来源:draw_example.php

示例12: analyzeImage

 /**
  * @param \Imagick $imagick
  * @param int $graphWidth
  * @param int $graphHeight
  */
 public static function analyzeImage(\Imagick $imagick, $graphWidth = 255, $graphHeight = 127)
 {
     $sampleHeight = 20;
     $border = 2;
     $imagick->transposeImage();
     $imagick->scaleImage($graphWidth, $sampleHeight);
     $imageIterator = new \ImagickPixelIterator($imagick);
     $luminosityArray = [];
     foreach ($imageIterator as $row => $pixels) {
         /* Loop through pixel rows */
         foreach ($pixels as $column => $pixel) {
             /* Loop through the pixels in the row (columns) */
             /** @var $pixel \ImagickPixel */
             if (false) {
                 $color = $pixel->getColor();
                 $luminosityArray[] = $color['r'];
             } else {
                 $hsl = $pixel->getHSL();
                 $luminosityArray[] = $hsl['luminosity'];
             }
         }
         /* Sync the iterator, this is important to do on each iteration */
         $imageIterator->syncIterator();
         break;
     }
     $draw = new \ImagickDraw();
     $strokeColor = new \ImagickPixel('red');
     $fillColor = new \ImagickPixel('red');
     $draw->setStrokeColor($strokeColor);
     $draw->setFillColor($fillColor);
     $draw->setStrokeWidth(0);
     $draw->setFontSize(72);
     $draw->setStrokeAntiAlias(true);
     $previous = false;
     $x = 0;
     foreach ($luminosityArray as $luminosity) {
         $pos = $graphHeight - 1 - $luminosity * ($graphHeight - 1);
         if ($previous !== false) {
             /** @var $previous int */
             //printf ( "%d, %d, %d, %d <br/>\n" , $x - 1, $previous, $x, $pos);
             $draw->line($x - 1, $previous, $x, $pos);
         }
         $x += 1;
         $previous = $pos;
     }
     $plot = new \Imagick();
     $plot->newImage($graphWidth, $graphHeight, 'white');
     $plot->drawImage($draw);
     $outputImage = new \Imagick();
     $outputImage->newImage($graphWidth, $graphHeight + $sampleHeight, 'white');
     $outputImage->compositeimage($plot, \Imagick::COMPOSITE_ATOP, 0, 0);
     $outputImage->compositeimage($imagick, \Imagick::COMPOSITE_ATOP, 0, $graphHeight);
     $outputImage->borderimage('black', $border, $border);
     $outputImage->setImageFormat("png");
     App::cachingHeader("Content-Type: image/png");
     echo $outputImage;
 }
开发者ID:danack,项目名称:imagick-demos,代码行数:62,代码来源:Image.php

示例13: box

 /**
  * (non-PHPdoc)
  * @see Imagine\Image\FontInterface::box()
  */
 public function box($string, $angle = 0)
 {
     $text = new \ImagickDraw();
     $text->setFont($this->file);
     $text->setFontSize($this->size);
     $info = $this->imagick->queryFontMetrics($text, $string);
     $box = new Box($info['textWidth'], $info['textHeight']);
     return $box;
 }
开发者ID:SerdarSanri,项目名称:laravel-imagine-bundle,代码行数:13,代码来源:Font.php

示例14: box

 /**
  * {@inheritdoc}
  */
 public function box($string, $angle = 0)
 {
     $text = new \ImagickDraw();
     $text->setFont($this->file);
     /**
      * @see http://www.php.net/manual/en/imagick.queryfontmetrics.php#101027
      *
      * ensure font resolution is the same as GD's hard-coded 96
      */
     if (version_compare(phpversion("imagick"), "3.0.2", ">=")) {
         $text->setResolution(96, 96);
         $text->setFontSize($this->size);
     } else {
         $text->setFontSize((int) ($this->size * (96 / 72)));
     }
     $info = $this->imagick->queryFontMetrics($text, $string);
     $box = new Box($info['textWidth'], $info['textHeight']);
     return $box;
 }
开发者ID:anillaogi016,项目名称:zend-admin,代码行数:22,代码来源:Font.php

示例15: render

 function render()
 {
     $text = "Lorem ipsum";
     $im = new \Imagick();
     $draw = new \ImagickDraw();
     $draw->setStrokeColor("none");
     $draw->setFont("../fonts/Arial.ttf");
     $draw->setFontSize(96);
     $draw->setTextAlignment(\Imagick::ALIGN_LEFT);
     $metrics = $im->queryFontMetrics($draw, $text);
     return print_table($metrics);
 }
开发者ID:sdmmember,项目名称:Imagick-demos,代码行数:12,代码来源:queryFontMetrics.php


注:本文中的ImagickDraw::setFontSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。