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


PHP ImagickDraw类代码示例

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


在下文中一共展示了ImagickDraw类的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: generateImage

 private function generateImage()
 {
     $this->generatedImage = new \Imagick();
     $rgbBackgroundColor = $this->getBackgroundColor();
     if (null === $rgbBackgroundColor) {
         $background = 'none';
     } else {
         $background = new \ImagickPixel("rgb({$rgbBackgroundColor['0']},{$rgbBackgroundColor['1']},{$rgbBackgroundColor['2']})");
     }
     $this->generatedImage->newImage($this->pixelRatio * 5, $this->pixelRatio * 5, $background, 'png');
     // prepare color
     $rgbColor = $this->getColor();
     $color = new \ImagickPixel("rgb({$rgbColor['0']},{$rgbColor['1']},{$rgbColor['2']})");
     $draw = new \ImagickDraw();
     $draw->setFillColor($color);
     // draw the content
     foreach ($this->getArrayOfSquare() as $lineKey => $lineValue) {
         foreach ($lineValue as $colKey => $colValue) {
             if (true === $colValue) {
                 $draw->rectangle($colKey * $this->pixelRatio, $lineKey * $this->pixelRatio, ($colKey + 1) * $this->pixelRatio, ($lineKey + 1) * $this->pixelRatio);
             }
         }
     }
     $this->generatedImage->drawImage($draw);
     return $this;
 }
开发者ID:dalinhuang,项目名称:Teaching-interactive-web-platform,代码行数:26,代码来源:ImageMagickGenerator.php

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

示例4: histogram

 public function histogram()
 {
     for ($i = 0; $i <= 256; $i++) {
         $this->data[$i] = array('r' => 0, 'g' => 0, 'b' => 0, 'y' => 0);
     }
     $this->iterate('hist_prepare');
     $maxPixelCount = 0;
     foreach ($this->data as $k => $v) {
         $maxPixelCount = max($maxPixelCount, $v['r'], $v['g'], $v['b'], $v['y']);
     }
     $this->img->newImage(512, 512, new ImagickPixel('white'));
     $this->img->setImageFormat('png');
     $draw = new ImagickDraw();
     for ($i = 0; $i < 257; $i++) {
         $draw->setStrokeColor('#ff0000');
         $draw->line($i * 2, 512, $i * 2, 512 - $this->data[$i]['r'] / $maxPixelCount * 512);
         $draw->setStrokeColor('#00ff00');
         $draw->line($i * 2, 512, $i * 2, 512 - $this->data[$i]['g'] / $maxPixelCount * 512);
         $draw->setStrokeColor('#0000ff');
         $draw->line($i * 2, 512, $i * 2, 512 - $this->data[$i]['b'] / $maxPixelCount * 512);
         $draw->setStrokeColor('#aaaaaa');
         $draw->line($i * 2, 512, $i * 2, 512 - $this->data[$i]['y'] / $maxPixelCount * 512);
     }
     $this->img->drawImage($draw);
 }
开发者ID:Atiragram,项目名称:poit-labs,代码行数:25,代码来源:fksistagram.php

示例5: drawBackground

 /**
  * Draws the background colour for the signature.
  * Note that this has no relation to {@link Card}s.
  *
  * @param $hexColour string Hexadecimal colour value
  */
 protected function drawBackground($hexColour)
 {
     $background = new ImagickDraw();
     $background->setFillColor($hexColour);
     $background->rectangle(0, 0, $this->canvas->getImageWidth(), $this->canvas->getImageHeight());
     $this->canvas->drawImage($background);
 }
开发者ID:BTCTaras,项目名称:osusig,代码行数:13,代码来源:Signature.php

示例6: image

 private static function image($frame, $pixelPerPoint = 4, $outerFrame = 4, $format = "png", $quality = 85, $filename = FALSE, $save = TRUE, $print = false)
 {
     $imgH = count($frame);
     $imgW = strlen($frame[0]);
     $col[0] = new \ImagickPixel("white");
     $col[1] = new \ImagickPixel("black");
     $image = new \Imagick();
     $image->newImage($imgW, $imgH, $col[0]);
     $image->setCompressionQuality($quality);
     $image->setImageFormat($format);
     $draw = new \ImagickDraw();
     $draw->setFillColor($col[1]);
     for ($y = 0; $y < $imgH; $y++) {
         for ($x = 0; $x < $imgW; $x++) {
             if ($frame[$y][$x] == '1') {
                 $draw->point($x, $y);
             }
         }
     }
     $image->drawImage($draw);
     $image->borderImage($col[0], $outerFrame, $outerFrame);
     $image->scaleImage(($imgW + 2 * $outerFrame) * $pixelPerPoint, 0);
     if ($save) {
         if ($filename === false) {
             throw new Exception("QR Code filename can't be empty");
         }
         $image->writeImages($filename, true);
     }
     if ($print) {
         Header("Content-type: image/" . $format);
         echo $image;
     }
 }
开发者ID:alveos,项目名称:phpqrcode,代码行数:33,代码来源:QRimage.php

示例7: drawLine

 /**
  * Draw line between points
  * Нарисовать линии между указанными точками
  * @param int $sx
  * @param int $sy
  * @param int $ex
  * @param int $ey
  */
 public function drawLine($sx, $sy, $ex, $ey)
 {
     $draw = new \ImagickDraw();
     $draw->setStrokeColor($this->black);
     $draw->setStrokeWidth(1);
     $draw->line($sx, $sy, $ex, $ey);
     $this->drawImage($draw);
 }
开发者ID:Cherkesov,项目名称:GFB-MosaicBundle,代码行数:16,代码来源:ImagickExt.php

示例8: fill

 /**
  * Flood the image with a color fill.
  *
  * @param  int $r
  * @param  int $g
  * @param  int $b
  * @return Imagick
  */
 public function fill($r, $g, $b)
 {
     $draw = new \ImagickDraw();
     $draw->setFillColor($this->image->getColor([(int) $r, (int) $g, (int) $b]));
     $draw->rectangle(0, 0, $this->image->getWidth(), $this->image->getHeight());
     $this->image->resource()->drawImage($draw);
     return $this;
 }
开发者ID:Nnadozieomeonu,项目名称:lacecart,代码行数:16,代码来源:Imagick.php

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

示例10: applyToImage

 /**
  * Draw current instance of line to given endpoint on given image
  *
  * @param  Image   $image
  * @param  integer $x
  * @param  integer $y
  * @return boolean
  */
 public function applyToImage(Image $image, $x = 0, $y = 0)
 {
     $line = new \ImagickDraw();
     $color = new Color($this->color);
     $line->setStrokeColor($color->getPixel());
     $line->setStrokeWidth($this->width);
     $line->line($this->x, $this->y, $x, $y);
     $image->getCore()->drawImage($line);
     return true;
 }
开发者ID:hilmysyarif,项目名称:sic,代码行数:18,代码来源:LineShape.php

示例11: draw

 /**
  * @param ImageInterface $image
  * @return Image
  */
 public function draw($image)
 {
     // Localize vars
     $width = $image->getWidth();
     $height = $image->getHeight();
     $imagick = $image->getCore();
     $draw = new \ImagickDraw();
     $strokeColor = new \ImagickPixel($this->getColor()->getHexString());
     $fillColor = new \ImagickPixel('rgba(0,0,0,0)');
     $draw->setStrokeOpacity(1);
     $draw->setStrokeColor($strokeColor);
     $draw->setFillColor($fillColor);
     list($x1, $y1) = $this->point1;
     list($x2, $y2) = $this->control;
     list($x3, $y3) = $this->point2;
     $draw->pathStart();
     $draw->pathMoveToAbsolute($x1, $y1);
     $draw->pathCurveToQuadraticBezierAbsolute($x2, $y2, $x3, $y3);
     $draw->pathFinish();
     // Render the draw commands in the ImagickDraw object
     $imagick->drawImage($draw);
     $type = $image->getType();
     $file = $image->getImageFile();
     return new Image($imagick, $file, $width, $height, $type);
     // Create new image with updated core
 }
开发者ID:kosinix,项目名称:grafika,代码行数:30,代码来源:QuadraticBezier.php

示例12: blueDiscAlpha

function blueDiscAlpha($width, $height)
{
    $imagick = new Imagick();
    $imagick->newImage($width, $height, 'none');
    $draw = new ImagickDraw();
    $draw->setStrokeOpacity(0);
    $draw->setFillColor('blue');
    $draw->circle(2 * $width / 3, 2 * $height / 3, $width - ($width / 3 - $width / 4), 2 * $height / 3);
    $imagick->drawImage($draw);
    return $imagick;
}
开发者ID:atawsports2,项目名称:Imagick-demos,代码行数:11,代码来源:createSourceImages.php

示例13: perform

 /**
  * Draws some text on the handle
  *
  * @param Zend_Image_Adapter_ImageMagick $adapter Adapter
  * @param Zend_Image_Action_DrawText $textObject The object that with all info
  */
 public function perform($adapter, Zend_Image_Action_DrawText $textObject)
 {
     // As of ZF2.0 / PHP5.3, this can be made static.
     $handle = $adapter->getHandle();
     $color = new ImagickPixel('#000000');
     // . $textObject->getColor());
     $draw = new ImagickDraw();
     $draw->annotation($textObject->getOffsetX(), $textObject->getOffsetY(), $textObject->getText());
     $handle->drawImage($draw);
     return $handle;
 }
开发者ID:BGCX262,项目名称:zym-svn-to-git,代码行数:17,代码来源:DrawText.php

示例14: draw

 /**
  * @param Image $image
  *
  * @return Image
  */
 public function draw($image)
 {
     $strokeColor = new \ImagickPixel($this->getColor()->getHexString());
     $draw = new \ImagickDraw();
     $draw->setStrokeColor($strokeColor);
     $draw->setStrokeWidth($this->thickness);
     list($x1, $y1) = $this->point1;
     list($x2, $y2) = $this->point2;
     $draw->line($x1, $y1, $x2, $y2);
     $image->getCore()->drawImage($draw);
     return $image;
 }
开发者ID:kosinix,项目名称:grafika,代码行数:17,代码来源:Line.php

示例15: execute

 /**
  * Draws one pixel to a given image
  *
  * @param  Intervention\Image\Image $image
  * @return boolean
  */
 public function execute($image)
 {
     $color = $this->argument(0)->required()->value();
     $color = new Color($color);
     $x = $this->argument(1)->type('integer')->required()->value();
     $y = $this->argument(2)->type('integer')->required()->value();
     // prepare pixel
     $draw = new \ImagickDraw();
     $draw->setFillColor($color->getPixel());
     $draw->point($x, $y);
     // apply pixel
     return $image->getCore()->drawImage($draw);
 }
开发者ID:RHoKAustralia,项目名称:onaroll21_backend,代码行数:19,代码来源:PixelCommand.php


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