當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。