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


PHP ImagickDraw::setStrokeAntialias方法代码示例

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


在下文中一共展示了ImagickDraw::setStrokeAntialias方法的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: 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)");
     $color['transparent'] = new ImagickPixel("transparent");
     // Prepare canvas for drawing main graph
     $draw = new ImagickDraw();
     $draw->setStrokeAntialias(true);
     $draw->setStrokeWidth(2);
     // 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->setFont(realpath('stuff/consola.ttf'));
     $draw->setFontSize(10);
     $draw->setFillColor($color['neutral']);
     $draw->annotation(self::WIDTH / 2, 26, "рейтинг: " . $this->_rate);
     $this->_canvas->drawImage($draw);
     $draw->destroy();
     $draw = new ImagickDraw();
     $draw->setTextAlignment(Imagick::ALIGN_CENTER);
     $draw->setTextAntialias(true);
     $draw->setTextUnderColor($color['karma']);
     $draw->setFillColor($color['bg']);
     $draw->setFontSize(12);
     $draw->setFont(realpath('stuff/consolab.ttf'));
     $draw->annotation(self::WIDTH / 4 + 1, 12, sprintf('%01.2f', $this->_karma));
     $draw->setTextUnderColor($color['force']);
     $draw->setFillColor($color['bg']);
     $draw->annotation(self::WIDTH / 4 * 3 - 1, 12, sprintf('%01.2f', $this->_habraforce));
     $this->_canvas->drawImage($draw);
     $draw->destroy();
     return true;
 }
开发者ID:lknight,项目名称:habrometr,代码行数:51,代码来源:88x31.php

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

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

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

示例8: addWatermark

 public function addWatermark($inputImage, $fileType = null, $viewingUser = null, $isRebuild = false)
 {
     $this->standardizeViewingUserReference($viewingUser);
     $fileType = $this->getImageFileType($inputImage, $fileType);
     if ($fileType === null) {
         return false;
     }
     $xenOptions = XenForo_Application::getOptions();
     if (empty($xenOptions->sonnbXG_watermark['enabled'])) {
         return false;
     }
     $isImagick = $xenOptions->imageLibrary['class'] === 'imPecl';
     $watermarkOptions = $this->getWatermarkSettings($isRebuild);
     try {
         switch ($watermarkOptions['overlay']) {
             case 'image':
                 $watermarkFile = tempnam(XenForo_Helper_File::getTempDir(), 'xf');
                 if (Zend_Uri::check($watermarkOptions['url'])) {
                     $client = XenForo_Helper_Http::getClient($watermarkOptions['url']);
                     $response = $client->request('GET');
                     if ($response->isSuccessful()) {
                         @file_put_contents($watermarkFile, $response->getBody());
                     } else {
                         return false;
                     }
                 } elseif (is_file($watermarkOptions['url'])) {
                     $this->copyFile($watermarkOptions['url'], $watermarkFile);
                 } else {
                     return false;
                 }
                 if (!($watermarkFileInfo = @getimagesize($watermarkFile))) {
                     return false;
                 }
                 if ($isImagick) {
                     $srcResource = new Imagick($inputImage);
                     $wtmResource = new Imagick($watermarkFile);
                 } else {
                     $srcResource = $this->createImageFromFile($inputImage, $fileType);
                     //TODO: Check watermark image size against input image.
                     $wtmResource = $this->createImageFromFile($watermarkFile, $watermarkFileInfo[2]);
                 }
                 $this->addWatermarkBySource($srcResource, $wtmResource, $watermarkOptions['position'], $watermarkOptions['margin'], $inputImage, $fileType);
                 @unlink($watermarkFile);
                 break;
             case 'text':
             default:
                 $findArray = array('{username}', '{user_id}', '{email}');
                 $replaceArray = array($viewingUser['username'], $viewingUser['user_id'], $viewingUser['email']);
                 $watermarkOptions['text'] = str_replace($findArray, $replaceArray, $watermarkOptions['text']);
                 if (empty($watermarkOptions['text'])) {
                     return false;
                 }
                 if ($isImagick) {
                     $wtmResource = new Imagick();
                     $draw = new ImagickDraw();
                     $color = new ImagickPixel($watermarkOptions['textColor']);
                     $background = new ImagickPixel('none');
                     $draw->setFontSize($watermarkOptions['textSize']);
                     $draw->setFillColor($color);
                     $draw->setStrokeAntialias(true);
                     $draw->setTextAntialias(true);
                     $metrics = $wtmResource->queryFontMetrics($draw, $watermarkOptions['text']);
                     $draw->annotation(0, $metrics['ascender'], $watermarkOptions['text']);
                     $wtmResource->newImage($metrics['textWidth'], $metrics['textHeight'], $background);
                     $wtmResource->setImageFormat('png');
                     $wtmResource->drawImage($draw);
                     $srcResource = new Imagick($inputImage);
                 } else {
                     $padding = 10;
                     $font = 'styles/sonnb/XenGallery/watermark.ttf';
                     if (!empty($watermarkOptions['font']) && is_file($watermarkOptions['font'])) {
                         $font = $watermarkOptions['font'];
                     }
                     if (function_exists('imagettfbbox')) {
                         $textDimension = imagettfbbox($watermarkOptions['textSize'], 0, $font, $watermarkOptions['text']);
                         $width = abs($textDimension[4] - $textDimension[0]) + $padding;
                         $height = abs($textDimension[5] - $textDimension[1]) + $padding;
                     } else {
                         $width = ImageFontWidth($watermarkOptions['textSize']) * strlen($watermarkOptions['text']);
                         $height = ImageFontHeight($watermarkOptions['textSize']);
                     }
                     $wtmResource = @imagecreatetruecolor($width, $height);
                     if (strtolower($watermarkOptions['bgColor']) === 'transparent') {
                         imagesavealpha($wtmResource, true);
                         $bgColor = imagecolorallocatealpha($wtmResource, 0, 0, 0, 127);
                         imagefill($wtmResource, 0, 0, $bgColor);
                     } else {
                         $bgColorRbg = $this->hex2rgb($watermarkOptions['bgColor']);
                         $bgColor = imagecolorallocate($wtmResource, $bgColorRbg['red'], $bgColorRbg['green'], $bgColorRbg['blue']);
                         imagefill($wtmResource, 0, 0, $bgColor);
                     }
                     $txtColorRbg = $this->hex2rgb($watermarkOptions['textColor']);
                     $txtColor = imagecolorallocate($wtmResource, $txtColorRbg['red'], $txtColorRbg['green'], $txtColorRbg['blue']);
                     imagettftext($wtmResource, $watermarkOptions['textSize'], 0, $padding / 2, $height - $padding / 2, $txtColor, $font, $watermarkOptions['text']);
                     $srcResource = $this->createImageFromFile($inputImage, $fileType);
                 }
                 $this->addWatermarkBySource($srcResource, $wtmResource, $watermarkOptions['position'], $watermarkOptions['margin'], $inputImage, $fileType);
                 break;
         }
     } catch (Exception $e) {
//.........这里部分代码省略.........
开发者ID:Sywooch,项目名称:forums,代码行数:101,代码来源:ContentData.php

示例9: 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->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(80, 13, $code);
     $textInfo = $this->_canvas->queryFontMetrics($draw, $code, null);
     $nextX = 80 + 9 + $textInfo['textWidth'];
     $draw->setFont(realpath('stuff/consola.ttf'));
     $draw->setFontSize(11);
     $draw->setFillColor($color['neutral']);
     $draw->annotation(5, 13, "хаброметр");
     $draw->setTextUnderColor($color['karma']);
     $draw->setFillColor($color['bg']);
     $draw->setFontSize(12);
     $draw->setFont(realpath('stuff/consolab.ttf'));
     $draw->annotation($nextX, 13, $text = sprintf('%01.2f', $this->_karma));
     $textInfo = $this->_canvas->queryFontMetrics($draw, $text, null);
     $nextX += $textInfo['textWidth'] + 4;
     $draw->setTextUnderColor($color['bg']);
     $draw->setFont(realpath('stuff/arialbd.ttf'));
     $text = sprintf('%01.2f', $this->_extremums['karma_min']) . '/' . sprintf('%01.2f', $this->_extremums['karma_max']);
     $draw->setFontSize(8);
     $draw->setFillColor($color['karma']);
     $draw->annotation($nextX, 13, $text);
     $textInfo = $this->_canvas->queryFontMetrics($draw, $text, null);
     $nextX += $textInfo['textWidth'] + 9;
     $draw->setFontSize(12);
     $draw->setFont(realpath('stuff/consolab.ttf'));
     $draw->setTextUnderColor($color['force']);
     $draw->setFillColor($color['bg']);
     $draw->annotation($nextX, 13, $text = sprintf('%01.2f', $this->_habraforce));
     $textInfo = $this->_canvas->queryFontMetrics($draw, $text, null);
     $nextX += $textInfo['textWidth'] + 4;
     $draw->setTextUnderColor($color['bg']);
     $draw->setFont(realpath('stuff/arialbd.ttf'));
     $text = sprintf('%01.2f', $this->_extremums['habraforce_min']) . '/' . sprintf('%01.2f', $this->_extremums['habraforce_max']);
     $draw->setFontSize(8);
     $draw->setFillColor($color['force']);
     $draw->annotation($nextX, 13, $text);
     $image = new Imagick('stuff/bg-user2.gif');
     $this->_canvas->compositeImage($image, Imagick::COMPOSITE_COPY, 64, 3, Imagick::CHANNEL_ALL);
     $image->clear();
     $image->destroy();
     $this->_canvas->drawImage($draw);
     $draw->destroy();
     return true;
 }
开发者ID:lknight,项目名称:habrometr,代码行数:81,代码来源:350x20.php

示例10: imagickDrawText

 /**
  * 在图片上添加验证文字
  * @param  resource $image         图片对象
  * @param  string   $text          要添加的字符
  * @return resource 图片对象
  */
 protected function imagickDrawText($image, $text)
 {
     $draw = new \ImagickDraw();
     $draw->setFont($this->font);
     $draw->setFontSize($this->height * 0.8);
     $draw->setFillColor(new \ImagickPixel('#333333'));
     $draw->setStrokeAntialias(true);
     $draw->setTextAntialias(true);
     $metrics = $image->queryFontMetrics($draw, $text);
     $draw->annotation(0, $metrics['ascender'], $text);
     $image->drawImage($draw);
     $draw->destroy();
     return $image;
 }
开发者ID:feixingbeibao,项目名称:vitexframework,代码行数:20,代码来源:Captcha.php

示例11: setStrokeAntialias

function setStrokeAntialias($strokeColor, $fillColor, $backgroundColor)
{
    $draw = new \ImagickDraw();
    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);
    $draw->setStrokeWidth(1);
    $draw->setStrokeAntialias(false);
    $draw->line(100, 100, 400, 105);
    $draw->line(100, 140, 400, 185);
    $draw->setStrokeAntialias(true);
    $draw->line(100, 110, 400, 115);
    $draw->line(100, 150, 400, 195);
    $image = new \Imagick();
    $image->newImage(500, 250, $backgroundColor);
    $image->setImageFormat("png");
    $image->drawImage($draw);
    header("Content-Type: image/png");
    echo $image->getImageBlob();
}
开发者ID:sdmmember,项目名称:Imagick-demos,代码行数:19,代码来源:functions.php

示例12: ImagickPixel

$draw->setClipRule(Imagick::FILLRULE_EVENODD);
var_dump($draw->getClipRule() === Imagick::FILLRULE_EVENODD);
$draw->setClipUnits(10);
var_dump($draw->getClipUnits());
// fill
$draw->setFillColor('yellow');
var_dump($draw->getFillColor()->getColor());
$draw->setFillOpacity(0.5);
printf("%.2f\n", $draw->getFillOpacity());
$draw->setFillRule(Imagick::FILLRULE_NONZERO);
var_dump($draw->getClipRule() === Imagick::FILLRULE_NONZERO);
// gravity
$draw->setGravity(Imagick::GRAVITY_SOUTHEAST);
var_dump($draw->getGravity() === Imagick::GRAVITY_SOUTHEAST);
// stroke
$draw->setStrokeAntialias(false);
var_dump($draw->getStrokeAntialias());
$draw->setStrokeColor(new ImagickPixel('#F02B88'));
var_dump($draw->getStrokeColor()->getColor());
$draw->setStrokeDashArray(array(1, 2, 3));
var_dump($draw->getStrokeDashArray());
$draw->setStrokeDashOffset(-1);
var_dump($draw->getStrokeDashOffset());
$draw->setStrokeLineCap(Imagick::LINECAP_SQUARE);
var_dump($draw->getStrokeLineCap() === Imagick::LINECAP_SQUARE);
$draw->setStrokeLineJoin(Imagick::LINEJOIN_BEVEL);
var_dump($draw->getStrokeLineJoin() === Imagick::LINEJOIN_BEVEL);
$draw->setStrokeMiterLimit(3);
var_dump($draw->getStrokeMiterLimit());
$draw->setStrokeOpacity(0.9);
printf("%.2f\n", $draw->getStrokeOpacity());
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:draw_accessor.php

示例13: getCoreBoxSize

 /**
  * Get raw boxsize without any non-core features
  *
  * @param  string $text
  * @return \Intervention\Image\Size
  */
 protected function getCoreBoxSize($text = null)
 {
     $text = is_null($text) ? $this->text : $text;
     $imagick = new \Imagick();
     $draw = new \ImagickDraw();
     $draw->setStrokeAntialias(true);
     $draw->setTextAntialias(true);
     $draw->setFontSize($this->size);
     $draw->setFont($this->file);
     // get boxsize
     $size = $imagick->queryFontMetrics($draw, $text);
     return new Size($size['textWidth'], $size['textHeight']);
 }
开发者ID:EdgarPost,项目名称:image,代码行数:19,代码来源:Font.php

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

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


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