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


PHP ImagickDraw::setTextAntialias方法代码示例

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


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

示例1: 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

示例2: 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

示例3: getImagineImage

 public function getImagineImage(ImagineInterface $imagine, FontCollection $fontCollection, $width, $height)
 {
     $fontPath = $fontCollection->getFontById($this->font)->getPath();
     if ($this->getAbsoluteSize() !== null) {
         $fontSize = $this->getAbsoluteSize();
     } elseif ($this->getRelativeSize() !== null) {
         $fontSize = (int) $this->getRelativeSize() / 100 * $height;
     } else {
         throw new \LogicException('Either relative or absolute watermark size must be set!');
     }
     if (true || !class_exists('ImagickDraw')) {
         // Fall back to ugly image.
         $palette = new \Imagine\Image\Palette\RGB();
         $font = $imagine->font($fontPath, $fontSize, $palette->color('#000'));
         $box = $font->box($this->getText());
         $watermarkImage = $imagine->create($box, $palette->color('#FFF'));
         $watermarkImage->draw()->text($this->text, $font, new \Imagine\Image\Point(0, 0));
     } else {
         // CURRENTLY DISABLED.
         // Use nicer Imagick implementation.
         // Untested!
         // @todo Test and implement it!
         $draw = new \ImagickDraw();
         $draw->setFont($fontPath);
         $draw->setFontSize($fontSize);
         $draw->setStrokeAntialias(true);
         //try with and without
         $draw->setTextAntialias(true);
         //try with and without
         $draw->setFillColor('#fff');
         $textOnly = new \Imagick();
         $textOnly->newImage(1400, 400, "transparent");
         //transparent canvas
         $textOnly->annotateImage($draw, 0, 0, 0, $this->text);
         //Create stroke
         $draw->setFillColor('#000');
         //same as stroke color
         $draw->setStrokeColor('#000');
         $draw->setStrokeWidth(8);
         $strokeImage = new \Imagick();
         $strokeImage->newImage(1400, 400, "transparent");
         $strokeImage->annotateImage($draw, 0, 0, 0, $this->text);
         //Composite text over stroke
         $strokeImage->compositeImage($textOnly, \Imagick::COMPOSITE_OVER, 0, 0, \Imagick::CHANNEL_ALPHA);
         $strokeImage->trimImage(0);
         //cut transparent border
         $watermarkImage = $imagine->load($strokeImage->getImageBlob());
         //$strokeImage->resizeImage(300,0, \Imagick::FILTER_CATROM, 0.9, false); //resize to final size
     }
     return $watermarkImage;
 }
开发者ID:shefik,项目名称:MediaModule,代码行数:51,代码来源:TextWatermarkEntity.php

示例4: applyToImage

 /**
  * Draws font to given image at given position
  *
  * @param  Image   $image
  * @param  integer $posx
  * @param  integer $posy
  * @return void
  */
 public function applyToImage(Image $image, $posx = 0, $posy = 0)
 {
     // build draw object
     $draw = new \ImagickDraw();
     $draw->setStrokeAntialias(true);
     $draw->setTextAntialias(true);
     // set font file
     if ($this->hasApplicableFontFile()) {
         $draw->setFont($this->file);
     } else {
         throw new \Intervention\Image\Exception\RuntimeException("Font file must be provided to apply text to image.");
     }
     // parse text color
     $color = new Color($this->color);
     $draw->setFontSize($this->size);
     $draw->setFillColor($color->getPixel());
     // align horizontal
     switch (strtolower($this->align)) {
         case 'center':
             $align = \Imagick::ALIGN_CENTER;
             break;
         case 'right':
             $align = \Imagick::ALIGN_RIGHT;
             break;
         default:
             $align = \Imagick::ALIGN_LEFT;
             break;
     }
     $draw->setTextAlignment($align);
     // align vertical
     if (strtolower($this->valign) != 'bottom') {
         // calculate box size
         $dimensions = $image->getCore()->queryFontMetrics($draw, $this->text);
         // corrections on y-position
         switch (strtolower($this->valign)) {
             case 'center':
             case 'middle':
                 $posy = $posy + $dimensions['textHeight'] * 0.65 / 2;
                 break;
             case 'top':
                 $posy = $posy + $dimensions['textHeight'] * 0.65;
                 break;
         }
     }
     // apply to image
     $image->getCore()->annotateImage($draw, $posx, $posy, $this->angle * -1, $this->text);
 }
开发者ID:hilmysyarif,项目名称:sic,代码行数:55,代码来源:Font.php

示例5: build

 public function build()
 {
     // Prepage image
     $this->_canvas = new Imagick();
     $this->_canvas->newImage(self::WIDTH, self::HEIGHT, new ImagickPixel("white"));
     $color['line'] = new ImagickPixel("rgb(216, 76, 64)");
     $color['text'] = new ImagickPixel("rgb(16, 35, 132)");
     $color['karma'] = new ImagickPixel("rgb(116, 194, 98)");
     $color['force'] = new ImagickPixel("rgb(37, 168, 255)");
     $color['bottom_bg'] = new ImagickPixel("rgb(255, 244, 224)");
     $color['bg'] = new ImagickPixel("white");
     $color['neutral'] = new ImagickPixel("rgb(200, 200, 200)");
     $color['habr'] = new ImagickPixel("rgb(83, 121, 139)");
     // Prepare canvas for drawing main graph
     $draw = new ImagickDraw();
     $draw->setStrokeAntialias(true);
     $draw->setStrokeWidth(2);
     // Prepare values for drawing main graph
     define('PADDING', 10);
     // Draw bottom bg
     define('TOP_SPACER', 10);
     $draw = new ImagickDraw();
     $draw->setFillColor($color['bg']);
     $draw->setStrokeColor($color['habr']);
     $draw->polyline(array(array('x' => 0, 'y' => 0), array('x' => self::WIDTH - 1, 'y' => 0), array('x' => self::WIDTH - 1, 'y' => self::HEIGHT - 1), array('x' => 0, 'y' => self::HEIGHT - 1), array('x' => 0, 'y' => 0)));
     $this->_canvas->drawImage($draw);
     $draw->destroy();
     // Draw texts
     $draw = new ImagickDraw();
     $draw->setTextAlignment(Imagick::ALIGN_CENTER);
     $draw->setTextAntialias(true);
     $draw->setFillColor($color['karma']);
     $draw->polyline(array(array('x' => 1, 'y' => 1), array('x' => self::WIDTH / 2, 'y' => 1), array('x' => self::WIDTH / 2, 'y' => self::HEIGHT - 2), array('x' => 1, 'y' => self::HEIGHT - 2), array('x' => 1, 'y' => 1)));
     $draw->setFillColor($color['bg']);
     $draw->setFontSize(11);
     $draw->setFont(realpath('stuff/consolab.ttf'));
     $draw->annotation(self::WIDTH / 4, 11, sprintf('%01.2f', $this->_karma));
     $draw->setFillColor($color['force']);
     $draw->polyline(array(array('x' => self::WIDTH / 2 + 1, 'y' => 1), array('x' => self::WIDTH - 2, 'y' => 1), array('x' => self::WIDTH - 2, 'y' => self::HEIGHT - 2), array('x' => self::WIDTH / 2 + 1, 'y' => self::HEIGHT - 2), array('x' => self::WIDTH / 2 + 1, 'y' => 1)));
     $draw->setFillColor($color['bg']);
     $draw->annotation(self::WIDTH / 4 * 3, 11, sprintf('%01.2f', $this->_habraforce));
     $this->_canvas->drawImage($draw);
     $draw->destroy();
     return true;
 }
开发者ID:lknight,项目名称:habrometr,代码行数:45,代码来源:88x15.php

示例6: writeText

 public 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 */
     if ($this->font !== null) {
         // Allow fallback on defaults as necessary
         $draw->setFont($this->font);
     }
     /* In Arial, size 21 looks good as a substitute for FONT_B, 24 for FONT_A */
     $draw->setFontSize($this->fontSize);
     $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);
     // debugging if you want to view the images yourself
     //$image -> writeImage("test.png");
     /* Save image */
     $escposImage = new ImagickEscposImage();
     $escposImage->readImageFromImagick($image);
     $size = Printer::IMG_DEFAULT;
     $this->printer->bitImage($escposImage, $size);
 }
开发者ID:mike42,项目名称:escpos-php,代码行数:38,代码来源:ImagePrintBuffer.php

示例7: imageGeometryReset

function imageGeometryReset()
{
    $draw = new \ImagickDraw();
    $draw->setFont("../fonts/Arial.ttf");
    $draw->setFontSize(48);
    $draw->setStrokeAntialias(true);
    $draw->setTextAntialias(true);
    $draw->setFillColor('#ff0000');
    $textOnly = new \Imagick();
    $textOnly->newImage(600, 300, "rgb(230, 230, 230)");
    $textOnly->setImageFormat('png');
    $textOnly->annotateImage($draw, 30, 40, 0, 'Your Text Here');
    $textOnly->trimImage(0);
    $textOnly->setImagePage($textOnly->getimageWidth(), $textOnly->getimageheight(), 0, 0);
    $distort = array(180);
    $textOnly->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TRANSPARENT);
    $textOnly->setImageMatte(true);
    $textOnly->distortImage(Imagick::DISTORTION_ARC, $distort, false);
    $textOnly->setformat('png');
    header("Content-Type: image/png");
    echo $textOnly->getimageblob();
}
开发者ID:biswajit-paul,项目名称:gittest,代码行数:22,代码来源:functions.php

示例8: showError

 /**
  * Show image with error text.
  *
  * @param string $text
  * @param int $width
  * @param int $height
  */
 public static function showError($text, $width, $height)
 {
     $canvas = new Imagick();
     $canvas->newImage($width, $height, new ImagickPixel("white"));
     $draw = new ImagickDraw();
     $draw->setFillColor(new ImagickPixel("white"));
     $draw->setStrokeColor(new ImagickPixel("black"));
     $draw->polyline(array(array('x' => 0, 'y' => 0), array('x' => $width - 1, 'y' => 0), array('x' => $width - 1, 'y' => $height - 1), array('x' => 0, 'y' => $height - 1), array('x' => 0, 'y' => 0)));
     $canvas->drawImage($draw);
     $draw->destroy();
     $draw = new ImagickDraw();
     $draw->setFillColor(new ImagickPixel("black"));
     $draw->setFontSize(12);
     $draw->setTextAlignment(Imagick::ALIGN_CENTER);
     $draw->setTextAntialias(true);
     $draw->setFont(realpath('stuff/consolab.ttf'));
     $draw->annotation($width / 2, $height / 2, $text);
     $canvas->drawImage($draw);
     $canvas->setImageFormat('png');
     header("Content-Type: image/png");
     echo $canvas;
     $draw->destroy();
     $canvas->clear();
     $canvas->destroy();
     exit;
 }
开发者ID:lknight,项目名称:habrometr,代码行数:33,代码来源:Informer.php

示例9: GetView


//.........这里部分代码省略.........
     $step = 3600000000.0;
     try {
         $conn = new PDO("mysql:host={$servername};dbname={$dbname}", $username, $password);
         // set the PDO error mode to exception
         $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         while (true) {
             if ($current >= $end) {
                 break;
             }
             $start_interval = $current;
             $end_interval = $start_interval + $step;
             $sql = "SELECT img_id, image, timestamp FROM Profiles_060_WTH_STATIC_EL90_Images_Stitch_Im1_3600 WHERE timestamp >= " . $start_interval . " AND timestamp < " . $end_interval;
             $stmt = $conn->query($sql);
             $row = $stmt->fetchObject();
             if ($row == false) {
                 $im->newImage($width, $height - $height * 20 / 100, "white");
             } else {
                 if (is_null($row->image)) {
                     $im->newImage($width, $height - $height * 20 / 100, "white");
                 } else {
                     $im->readimageblob($row->image);
                     $im->resizeImage($width, $height - $height * 20 / 100, Imagick::FILTER_LANCZOS, 1);
                 }
             }
             #$text = date('H:s', ($current / 1000000));
             #$draw = new ImagickDraw();
             $tick = new ImagickDraw();
             $ceiling = new ImagickDraw();
             /* Font properties */
             #$draw->setFont('Arial');
             #$draw->setFontSize(200);
             #$draw->setFillColor($color);
             #$draw->setStrokeAntialias(true);
             #$draw->setTextAntialias(true);
             /* Get font metrics */
             #$metrics = $image->queryFontMetrics($draw, $text);
             /* Create text */
             #$draw->annotation(0, $metrics['ascender']+20, $text);
             $tick->setStrokeWidth(10);
             $tick->setStrokeColor($color);
             $tick->setFillColor($color);
             $tick->line(0, 0, 0, 20);
             //imageline($image, $width/2, 0, $width/2, 50, $color);
             $ceiling->setStrokeColor($color);
             $ceiling->setFillColor($color);
             $ceiling->line(0, 0, $width, 0);
             /* Create image */
             $image->newImage($width, 20, $background);
             $image->setImageFormat('png');
             #$image->drawImage($draw);
             $image->drawImage($tick);
             $image->drawImage($ceiling);
             $im->addImage($image);
             $im->resetIterator();
             $tmp = $im->appendImages(true);
             $final->addImage($tmp);
             $current = $end_interval;
             $im->clear();
             $image->clear();
             $tmp->clear();
             $tick->clear();
             $ceiling->clear();
         }
     } catch (PDOException $e) {
         //echo "Connection failed: " . $e->getMessage();
     }
     /* Append the images into one */
     $final->resetIterator();
     $combined = $final->appendImages(false);
     /* Output the image */
     $combined->setImageFormat("png");
     $combined->resizeImage($width, $height - $height * 20 / 100, Imagick::FILTER_LANCZOS, 1);
     $draw = new ImagickDraw();
     /* Font properties */
     $draw->setFont('Arial');
     $draw->setFontSize(12);
     $draw->setFillColor($color);
     $draw->setStrokeAntialias(true);
     $draw->setTextAntialias(true);
     $runner = $start;
     $axis_interval = $width / 24;
     $i = 0;
     while ($runner < $end) {
         $text = date('H:s', $runner / 1000000);
         $metrics = $image->queryFontMetrics($draw, $text);
         $draw->annotation($i * $axis_interval, $metrics['ascender'] + 20, $text);
         $runner = $runner + $step;
         $i++;
     }
     $xaxis = new Imagick();
     $xaxis->newImage($width, 50, $background);
     $xaxis->setImageFormat('png');
     $xaxis->drawImage($draw);
     $with_axes->addImage($combined);
     $with_axes->addImage($xaxis);
     $with_axes->resetIterator();
     $output = $with_axes->appendImages(true);
     file_put_contents("{$TMP_PATH}/{$tmp_file}", $output);
     return array("img" => array("id" => $tmp_file, "yaxis" => "testest"), "div" => array("class" => "image-player", "xml" => "<div id='media'>" . "<div style='width:100px; margin: 0 auto;'>1367539200000000</div>" . "<div id='jet' class='colormap'></div>" . "<div class='range'><p class='lower'>-2</p><p class='upper'>2</p></div>" . "<div style='clear: both;'></div>" . "<div id='media-controls'>" . "<button id='play-pause-button' title='play' onclick='togglePlayPause();'>Play</button>" . "<button id='stop-button' title='stop' onclick='stopPlay();'>Stop</button>" . "<progress id='progress-bar' min='0' max='100' value='0' style='width:" . ($width - $width * 10 / 100) . "px'>0% played</progress>" . "</div>" . "</div>" . "<div id='timestamp1' style='display: none;' data='" . $start . "'></div>" . "<div id='timestamp2' style='display: none;' data='0'></div>"));
 }
开发者ID:nicolaisi,项目名称:adei,代码行数:101,代码来源:pbview.php

示例10: text

 public function text($text, $font, $size, $color = "#00000000", $locate = THINKIMAGE_WATER_SOUTHEAST, $offset = 0, $angle = 0)
 {
     if (empty($this->img)) {
         throw new Exception("没有可以被写入文字的图像资源");
     }
     if (!is_file($font)) {
         throw new Exception("不存在的字体文件:{$font}");
     }
     if (is_array($color)) {
         $color = array_map("dechex", $color);
         foreach ($color as &$value) {
             $value = str_pad($value, 2, "0", STR_PAD_LEFT);
         }
         $color = "#" . implode("", $color);
     } else {
         if (!is_string($color) || 0 !== strpos($color, "#")) {
             throw new Exception("错误的颜色值");
         }
     }
     $col = substr($color, 0, 7);
     $alp = strlen($color) == 9 ? substr($color, -2) : 0;
     $draw = new ImagickDraw();
     $draw->setFont(realpath($font));
     $draw->setFontSize($size);
     $draw->setFillColor($col);
     $draw->setFillAlpha(1 - hexdec($alp) / 127);
     $draw->setTextAntialias(true);
     $draw->setStrokeAntialias(true);
     $metrics = $this->img->queryFontMetrics($draw, $text);
     $x = 0;
     $y = $metrics["ascender"];
     $w = $metrics["textWidth"];
     $h = $metrics["textHeight"];
     switch ($locate) {
         case THINKIMAGE_WATER_SOUTHEAST:
             $x += $this->info["width"] - $w;
             $y += $this->info["height"] - $h;
             break;
         case THINKIMAGE_WATER_SOUTHWEST:
             $y += $this->info["height"] - $h;
             break;
         case THINKIMAGE_WATER_NORTHWEST:
             break;
         case THINKIMAGE_WATER_NORTHEAST:
             $x += $this->info["width"] - $w;
             break;
         case THINKIMAGE_WATER_CENTER:
             $x += ($this->info["width"] - $w) / 2;
             $y += ($this->info["height"] - $h) / 2;
             break;
         case THINKIMAGE_WATER_SOUTH:
             $x += ($this->info["width"] - $w) / 2;
             $y += $this->info["height"] - $h;
             break;
         case THINKIMAGE_WATER_EAST:
             $x += $this->info["width"] - $w;
             $y += ($this->info["height"] - $h) / 2;
             break;
         case THINKIMAGE_WATER_NORTH:
             $x += ($this->info["width"] - $w) / 2;
             break;
         case THINKIMAGE_WATER_WEST:
             $y += ($this->info["height"] - $h) / 2;
             break;
         default:
             if (is_array($locate)) {
                 $posy = $locate[1];
                 $posx = $locate[0];
                 $x += $posx;
                 $y += $posy;
             } else {
                 throw new Exception("不支持的文字位置类型");
             }
     }
     if (is_array($offset)) {
         $offset = array_map("intval", $offset);
         $oy = $offset[1];
         $ox = $offset[0];
     } else {
         $offset = intval($offset);
         $ox = $oy = $offset;
     }
     if ("gif" == $this->info["type"]) {
         $img = $this->img->coalesceImages();
         $this->img->destroy();
         do {
             $img->annotateImage($draw, $x + $ox, $y + $oy, $angle, $text);
         } while ($img->nextImage());
         $this->img = $img->deconstructImages();
         $img->destroy();
     } else {
         $this->img->annotateImage($draw, $x + $ox, $y + $oy, $angle, $text);
     }
     $draw->destroy();
 }
开发者ID:AxelPanda,项目名称:ibos,代码行数:95,代码来源:ImageImagick.class.php

示例11: build

 public function build()
 {
     // Prepage image
     $this->_canvas = new Imagick();
     $this->_canvas->newImage(self::WIDTH, self::HEIGHT, new ImagickPixel("white"));
     $color['line'] = new ImagickPixel("rgb(216, 76, 64)");
     $color['text'] = new ImagickPixel("rgb(16, 35, 132)");
     $color['karma'] = new ImagickPixel("rgb(116, 194, 98)");
     $color['force'] = new ImagickPixel("rgb(37, 168, 255)");
     $color['bottom_bg'] = new ImagickPixel("rgb(255, 244, 224)");
     $color['bg'] = new ImagickPixel("white");
     $color['neutral'] = new ImagickPixel("rgb(200, 200, 200)");
     $color['habr'] = new ImagickPixel("rgb(83, 121, 139)");
     // Prepare canvas for drawing main graph
     $draw = new ImagickDraw();
     $draw->setStrokeAntialias(true);
     $draw->setStrokeWidth(2);
     // Prepare values for drawing main graph
     define('PADDING', 10);
     // Draw bottom bg
     define('TOP_SPACER', 10);
     $draw = new ImagickDraw();
     $draw->setFillColor($color['bg']);
     $draw->setStrokeColor($color['habr']);
     $draw->polyline(array(array('x' => 0, 'y' => 0), array('x' => self::WIDTH - 1, 'y' => 0), array('x' => self::WIDTH - 1, 'y' => self::HEIGHT - 1), array('x' => 0, 'y' => self::HEIGHT - 1), array('x' => 0, 'y' => 0)));
     $this->_canvas->drawImage($draw);
     $draw->destroy();
     // Draw texts
     $draw = new ImagickDraw();
     $draw->setTextUnderColor($color['bg']);
     $draw->setTextAlignment(Imagick::ALIGN_CENTER);
     $draw->setTextAntialias(true);
     $draw->setFillColor($color['text']);
     $draw->setFont(realpath('stuff/arialbd.ttf'));
     $code = $this->_user;
     $draw->setFontSize(strlen($code) > 8 ? 10 : 11);
     if (strlen($code) > 10) {
         $code = substr($code, 0, 9) . '...';
     }
     $draw->annotation(self::WIDTH / 2, self::HEIGHT - 9, $code);
     $draw->setFont(realpath('stuff/consola.ttf'));
     $draw->setFontSize(11);
     $draw->setFillColor($color['neutral']);
     $draw->annotation(self::WIDTH / 2, 15, "хаброметр");
     $text = sprintf('%01.2f', $this->_extremums['karma_min']) . ' / ' . sprintf('%01.2f', $this->_extremums['karma_max']);
     $draw->setFontSize(9);
     $draw->setFillColor($color['karma']);
     $draw->annotation(self::WIDTH / 2, 55, $text);
     $text = sprintf('%01.2f', $this->_extremums['habraforce_min']) . ' / ' . sprintf('%01.2f', $this->_extremums['habraforce_max']);
     $draw->setFontSize(9);
     $draw->setFillColor($color['force']);
     $draw->annotation(self::WIDTH / 2, 95, $text);
     $draw->setTextUnderColor($color['karma']);
     $draw->setFillColor($color['bg']);
     $draw->setFontSize(14);
     $draw->setFont(realpath('stuff/consolab.ttf'));
     $draw->annotation(self::WIDTH / 2, 35, sprintf('%01.2f', $this->_karma));
     $draw->setTextUnderColor($color['force']);
     $draw->setFillColor($color['bg']);
     $draw->annotation(self::WIDTH / 2, 75, sprintf('%01.2f', $this->_habraforce));
     $this->_canvas->drawImage($draw);
     $draw->destroy();
     return true;
 }
开发者ID:lknight,项目名称:habrometr,代码行数:64,代码来源:88x120.php

示例12: text

 /**
  * (non-PHPdoc)
  * @see Imagine\Draw\DrawerInterface::text()
  */
 public function text($string, AbstractFont $font, PointInterface $position, $angle = 0)
 {
     try {
         $pixel = $this->getColor($font->getColor());
         $text = new \ImagickDraw();
         $text->setFont($font->getFile());
         $text->setFontSize($font->getSize());
         $text->setFillColor($pixel);
         $text->setTextAntialias(true);
         $info = $this->imagick->queryFontMetrics($text, $string);
         $rad = deg2rad($angle);
         $cos = cos($rad);
         $sin = sin($rad);
         $x1 = round(0 * $cos - 0 * $sin);
         $x2 = round($info['textWidth'] * $cos - $info['textHeight'] * $sin);
         $y1 = round(0 * $sin + 0 * $cos);
         $y2 = round($info['textWidth'] * $sin + $info['textHeight'] * $cos);
         $xdiff = 0 - min($x1, $x2);
         $ydiff = 0 - min($y1, $y2);
         $this->imagick->annotateImage($text, $position->getX() + $x1 + $xdiff, $position->getY() + $y2 + $ydiff, $angle, $string);
         $pixel->clear();
         $pixel->destroy();
         $text->clear();
         $text->destroy();
     } catch (\ImagickException $e) {
         throw new RuntimeException('Draw text operation failed', $e->getCode(), $e);
     }
 }
开发者ID:nicodmf,项目名称:Imagine,代码行数:32,代码来源:Drawer.php

示例13: flush

 $state = $s['result'];
 $patternWidth = $state['patternWidth'];
 // Create Imagick objects
 echo '<li>initialisiere</li>';
 flush();
 $image = new Imagick();
 $draw = new ImagickDraw();
 $color = new ImagickPixel('black');
 $background = new ImagickPixel('white');
 // Set Font properties
 //$draw->setFont('Arial');
 $draw->setFont($fontname);
 $draw->setFontSize($fontsize);
 $draw->setFillColor($color);
 $draw->setStrokeAntialias(true);
 $draw->setTextAntialias(true);
 echo '<li>bestimme Dimension des Textes</li>';
 flush();
 // Get font metrics
 $metrics = $image->queryFontMetrics($draw, $text);
 // draw the text
 $topborder = 2;
 $spaceatend = 5;
 echo '<li>generiere Text</li>';
 flush();
 $draw->annotation(0, $topborder + $metrics['ascender'], $text);
 // create image of correct size
 echo '<li>generiere Bild</li>';
 flush();
 $image->newImage($spaceatend + $metrics['textWidth'], $topborder + $metrics['textHeight'], $background);
 $image->setImageFormat('png');
开发者ID:plan44,项目名称:p44ayabd,代码行数:31,代码来源:index.php

示例14: drawText

 /**
  * @see	wcf\system\image\adapter\IImageAdapter::drawText()
  */
 public function drawText($string, $x, $y)
 {
     $draw = new \ImagickDraw();
     $draw->setFillColor($this->color);
     $draw->setTextAntialias(true);
     // draw text
     $draw->annotation($x, $y, $string);
     $this->imagick->drawImage($draw);
 }
开发者ID:ZerGabriel,项目名称:WCF,代码行数:12,代码来源:ImagickImageAdapter.class.php

示例15: __getImage

 private static function __getImage($img, $type)
 {
     $client = new Client(Config::get('services.dropbox.token'), Config::get('services.dropbox.appName'));
     $fileSystem = new Filesystem(new DropboxAdapter($client, '/images/'));
     $biggerW = $biggerH = false;
     if ($img->width > $img->height) {
         $biggerW = true;
     } else {
         $biggerH = true;
     }
     $image = $w = $h = null;
     $public_path = public_path($img->path);
     //code minh
     //get image from dropbox
     if ($img->store == 'dropbox') {
         try {
             $file = $fileSystem->read($img->path);
             $public_path = $file;
         } catch (Exception $e) {
             return false;
         }
     }
     //end code
     if (in_array($type, ['with-logo', 'large-thumb'])) {
         if ($biggerW) {
             $w = 450;
         } else {
             $h = 450;
         }
     } else {
         if (in_array($type, ['thumb', 'small-thumb'])) {
             if ($type == 'thumb') {
                 if ($biggerW) {
                     $w = 150;
                 } else {
                     $h = 150;
                 }
             } else {
                 if ($biggerW) {
                     $w = 100;
                 } else {
                     $h = 100;
                 }
             }
         } else {
             if (in_array($type, ['crop', 'newcrop'])) {
                 $h = 300;
                 $w = 300;
                 if ($type == 'newcrop') {
                     $w = 600;
                 }
             }
         }
     }
     try {
         if (in_array($type, ['crop', 'newcrop'])) {
             $image = Image::make($public_path)->fit($w, $h, function ($constraint) {
                 $constraint->aspectRatio();
             });
         } else {
             $image = Image::make($public_path)->resize($w, $h, function ($constraint) {
                 $constraint->aspectRatio();
             });
         }
     } catch (Exception $e) {
         return false;
     }
     if ($type == 'with-logo') {
         if (Cache::has('mask')) {
             $mask = Cache::get('mask');
         } else {
             $mask = Configure::where('ckey', 'mask')->pluck('cvalue');
             if (empty($mask)) {
                 $mask = 'Visual Impact';
             }
             Cache::forever('mask', $mask);
         }
         $size = 50;
         $w = $image->width();
         $h = $image->height();
         $x = round($w / 2);
         $y = round($h / 2);
         $img = Image::canvas($w, $h);
         $string = wordwrap($mask, 15, '|');
         $strings = explode('|', $string);
         $line = 2;
         $i = round($y - count($strings) / 2 * ($size + $line));
         $from = $i - 20;
         foreach ($strings as $string) {
             $draw = new \ImagickDraw();
             $draw->setStrokeAntialias(true);
             $draw->setTextAntialias(true);
             $draw->setFont(public_path('assets' . DS . 'fonts' . DS . 'times.ttf'));
             $draw->setFontSize($size);
             $draw->setFillColor('rgb(0, 0, 0)');
             $draw->setFillOpacity(0.2);
             $draw->setTextAlignment(\Imagick::ALIGN_CENTER);
             $draw->setStrokeColor('#fff');
             $draw->setStrokeOpacity(0.2);
             $draw->setStrokeWidth(1);
//.........这里部分代码省略.........
开发者ID:nguyendaivu,项目名称:imagestock,代码行数:101,代码来源:VIImage.php


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