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


PHP ImagickDraw::polygon方法代码示例

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


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

示例1: perform

    /**
     * Draws a polygon on the handle
     *
     * @param ImageMagick-object $handle The handle on which the polygon is drawn
     * @param Zend_Image_Action_DrawPolygon $polygon The object that with all info
     */
    public function perform($handle, Zend_Image_Action_DrawPolygon $polygon) { // As of ZF2.0 / PHP5.3, this can be made static.
        
        $points = $this->_parsePoints($polygon->getPoints());

        if ($polygon->isClosed()){
            //add first point at the end to close
            $points[count($points)] = $points[0];
        }

        $draw = new ImagickDraw();

        $draw->setStrokeColor('#' . $polygon->getStrokeColor()->getHex());

        $draw->setStrokeOpacity($polygon->getStrokeAlpha()/100);
        $draw->setStrokeWidth($polygon->getStrokeWidth());

        $strokeDashArray = $polygon->getStrokeDashPattern();
        if (count($strokeDashArray) > 0){
            $draw->setStrokeDashArray($strokeDashArray);
        }
        $draw->setStrokeDashOffset($polygon->getStrokeDashOffset());

        if($polygon->isFilled()) {
            $fillColor = $polygon->getFillColor();
            $draw->setFillColor('#' . $fillColor->getHex());
            $draw->polygon($points);

        } else {
            //Use transparent fill to render unfilled
            $draw->setFillOpacity(0);
            $draw->polyline($points);
        }

        $handle->getHandle()->drawImage($draw);
    }
开发者ID:BGCX262,项目名称:zym-svn-to-git,代码行数:41,代码来源:DrawPolygon.php

示例2: draw_pie

function draw_pie(&$canvas, $ox, $oy, $r, $sd, $ed, $color)
{
    $draw = new ImagickDraw();
    $draw->setFillColor($color);
    $draw->setStrokeColor($color);
    $draw->setStrokeWidth(1);
    $draw->arc($ox - $r, $oy - $r, $ox + $r, $oy + $r, $sd, $ed);
    $draw->polygon(array(array('x' => $ox, 'y' => $oy), get_coord($ox, $oy, $r, $r, $sd), get_coord($ox, $oy, $r, $r, $ed)));
    $canvas->drawImage($draw);
}
开发者ID:badlamer,项目名称:hhvm,代码行数:10,代码来源:draw_example.php

示例3: applyToImage

 /**
  * Draw polygon on given image
  *
  * @param  Image   $image
  * @param  integer $x
  * @param  integer $y
  * @return boolean
  */
 public function applyToImage(Image $image, $x = 0, $y = 0)
 {
     $polygon = new \ImagickDraw();
     // set background
     $bgcolor = new Color($this->background);
     $polygon->setFillColor($bgcolor->getPixel());
     // set border
     if ($this->hasBorder()) {
         $border_color = new Color($this->border_color);
         $polygon->setStrokeWidth($this->border_width);
         $polygon->setStrokeColor($border_color->getPixel());
     }
     $polygon->polygon($this->points);
     $image->getCore()->drawImage($polygon);
     return true;
 }
开发者ID:alvarobfdev,项目名称:applog,代码行数:24,代码来源:PolygonShape.php

示例4: render

 public function render($pDatas)
 {
     $im = new Imagick();
     $im->newImage(300, 300, "white", "png");
     $draw = new ImagickDraw();
     foreach ($pDatas as $key => $data) {
         if ($data->value == 0) {
             continue;
         }
         $draw->setFillColor('red');
         $draw->setstrokecolor('black');
         $draw->polygon($data->polygons);
         $draw->setFillColor('black');
         $draw->setFontSize(18);
         $draw->annotation($data->center['x'], $data->center['y'] + 9, $data->value);
     }
     $im->drawimage($draw);
     return $im;
 }
开发者ID:Juliens,项目名称:JuliensCharts,代码行数:19,代码来源:index.php

示例5: draw

 public function draw($image)
 {
     $draw = new \ImagickDraw();
     $draw->setStrokeWidth($this->borderSize);
     if (null !== $this->fillColor) {
         $fillColor = new \ImagickPixel($this->fillColor->getHexString());
         $draw->setFillColor($fillColor);
     } else {
         $draw->setFillOpacity(0);
     }
     if (null !== $this->borderColor) {
         $borderColor = new \ImagickPixel($this->borderColor->getHexString());
         $draw->setStrokeColor($borderColor);
     } else {
         $draw->setStrokeOpacity(0);
     }
     $draw->polygon($this->points());
     $image->getCore()->drawImage($draw);
     return $image;
 }
开发者ID:kosinix,项目名称:grafika,代码行数:20,代码来源:Polygon.php

示例6: Imagick

<?php

/*
	This examples was ported from Imagemagick C examples.
*/
/* Create Imagick objects */
$Imagick = new Imagick();
/* Create ImagickDraw objects */
$ImagickDraw = new ImagickDraw();
/* Create ImagickPixel objects */
$ImagickPixel = new ImagickPixel();
/* This array contains polygon geometry */
$array = array(array("x" => 378.1, "y" => 81.72), array("x" => 381.1, "y" => 79.56), array("x" => 384.3, "y" => 78.12), array("x" => 387.6, "y" => 77.33), array("x" => 391.1, "y" => 77.11), array("x" => 394.6, "y" => 77.62), array("x" => 397.8, "y" => 78.77), array("x" => 400.9, "y" => 80.56999999999999), array("x" => 403.6, "y" => 83.02), array("x" => 523.9, "y" => 216.8), array("x" => 526.2, "y" => 219.7), array("x" => 527.6, "y" => 223), array("x" => 528.4, "y" => 226.4), array("x" => 528.6, "y" => 229.8), array("x" => 528.0, "y" => 233.3), array("x" => 526.9, "y" => 236.5), array("x" => 525.1, "y" => 239.5), array("x" => 522.6, "y" => 242.2), array("x" => 495.9, "y" => 266.3), array("x" => 493, "y" => 268.5), array("x" => 489.7, "y" => 269.9), array("x" => 486.4, "y" => 270.8), array("x" => 482.9, "y" => 270.9), array("x" => 479.5, "y" => 270.4), array("x" => 476.2, "y" => 269.3), array("x" => 473.2, "y" => 267.5), array("x" => 470.4, "y" => 265), array("x" => 350, "y" => 131.2), array("x" => 347.8, "y" => 128.3), array("x" => 346.4, "y" => 125.1), array("x" => 345.6, "y" => 121.7), array("x" => 345.4, "y" => 118.2), array("x" => 346, "y" => 114.8), array("x" => 347.1, "y" => 111.5), array("x" => 348.9, "y" => 108.5), array("x" => 351.4, "y" => 105.8), array("x" => 378.1, "y" => 81.72));
/* This ImagickPixel is used to set background color */
$ImagickPixel->setColor('gray');
/* Create new image, set color to gray and format to png*/
$Imagick->newImage(700, 500, $ImagickPixel);
$Imagick->setImageFormat('png');
/* Create the polygon*/
$ImagickDraw->polygon($array);
/* Render the polygon to image*/
$Imagick->drawImage($ImagickDraw);
/* Send headers and output the image */
header("Content-Type: image/{$Imagick->getImageFormat()}");
echo $Imagick->getImageBlob();
开发者ID:yuxianhua,项目名称:imagick,代码行数:25,代码来源:polygon.php

示例7: drawImage

function drawImage()
{
    $strokeColor = 'black';
    $fillColor = 'salmon';
    $backgroundColor = 'lightblue';
    $draw = new \ImagickDraw();
    $draw->setStrokeOpacity(1);
    $draw->setStrokeColor($strokeColor);
    $draw->setStrokeWidth(4);
    $draw->setFillColor($fillColor);
    $points = [['x' => 40 * 5, 'y' => 10 * 5], ['x' => 20 * 5, 'y' => 20 * 5], ['x' => 70 * 5, 'y' => 50 * 5], ['x' => 60 * 5, 'y' => 15 * 5]];
    $draw->polygon($points);
    $image = new \Imagick();
    $image->newImage(500, 300, $backgroundColor);
    $image->setImageFormat("png");
    $image->drawImage($draw);
    header("Content-Type: image/png");
    echo $image->getImageBlob();
}
开发者ID:biswajit-paul,项目名称:gittest,代码行数:19,代码来源:functions.php

示例8: writeImageWithApi

 /**
  * Based on an image specification, write such an image to disk, using Imagick PHP extension
  * @param array $spec Spec describing background and circles to draw
  * @param string $format File format to write
  * @param string $filename Filename to write to
  */
 public function writeImageWithApi($spec, $format, $filename)
 {
     // this is a hack because I can't get setImageOrientation() to work. See below.
     global $wgExiv2Command;
     $image = new Imagick();
     /**
      * If the format is 'jpg', will also add a random orientation -- the
      * image will be drawn rotated with triangle points facing in some
      * direction (0, 90, 180 or 270 degrees) and a countering rotation
      * should turn the triangle points upward again.
      */
     $orientation = self::$orientations[0];
     // default is normal orientation
     if ($format == 'jpg') {
         $orientation = self::$orientations[array_rand(self::$orientations)];
         $spec = self::rotateImageSpec($spec, $orientation['counterRotation']);
     }
     $image->newImage($spec['width'], $spec['height'], new ImagickPixel($spec['fill']));
     foreach ($spec['draws'] as $drawSpec) {
         $draw = new ImagickDraw();
         $draw->setFillColor($drawSpec['fill']);
         $draw->polygon($drawSpec['shape']);
         $image->drawImage($draw);
     }
     $image->setImageFormat($format);
     // this doesn't work, even though it's documented to do so...
     // $image->setImageOrientation( $orientation['exifCode'] );
     $image->writeImage($filename);
     // because the above setImageOrientation call doesn't work... nor can I
     // get an external imagemagick binary to do this either... Hacking this
     // for now (only works if you have exiv2 installed, a program to read
     // and manipulate exif).
     if ($wgExiv2Command) {
         $cmd = wfEscapeShellArg($wgExiv2Command) . " -M " . wfEscapeShellArg("set Exif.Image.Orientation " . $orientation['exifCode']) . " " . wfEscapeShellArg($filename);
         $retval = 0;
         $err = wfShellExec($cmd, $retval);
         if ($retval !== 0) {
             print "Error with {$cmd}: {$retval}, {$err}\n";
         }
     }
 }
开发者ID:jpena88,项目名称:mediawiki-dokku-deploy,代码行数:47,代码来源:RandomImageGenerator.php

示例9: slantRectangle

function slantRectangle(&$canvas, $x, $y, $w, $h, $color1, $image = 0)
{
    $background = "#FFFFFF";
    //$ltr = '#000000';
    $ltr = '#888';
    $bd = '#A6A6A6';
    $iglow = '#404040';
    try {
        $gradient1 = new Imagick();
        $gradient1->newPseudoImage($h, $w * 3 / 8, "gradient:white-{$ltr}");
        $gradient1->rotateImage(new ImagickPixel(), 270);
        $gradient2 = new Imagick();
        $gradient2->newPseudoImage($h, $w * 3 / 8, "gradient:{$ltr}-white");
        $gradient2->rotateImage(new ImagickPixel(), 270);
        $lefttoright = new Imagick();
        $lefttoright->newPseudoImage($w, $h, "xc:{$ltr}");
        $lefttoright->compositeImage($gradient1, imagick::COMPOSITE_OVER, 0, 0);
        $lefttoright->compositeImage($gradient2, imagick::COMPOSITE_OVER, $w * 5 / 8, 0);
        $whiteup = new Imagick();
        $whiteup->newPseudoImage($w, $h / 2, "gradient:black-#888");
        $gradient1 = new Imagick();
        $gradient1->newPseudoImage($w, $h / 7, "gradient:{$bd}-white");
        $gradient2 = new Imagick();
        $gradient2->newPseudoImage($w, $h / 7, "gradient:white-{$bd}");
        $bottomdark = new Imagick();
        $bottomdark->newPseudoImage($w, $h, "xc:white");
        $bottomdark->compositeImage($gradient1, imagick::COMPOSITE_OVER, 0, 0);
        $bottomdark->compositeImage($gradient2, imagick::COMPOSITE_OVER, 0, $h / 2 - $h / 7);
        $background = new Imagick();
        $background->newPseudoImage($w, $h, "xc:{$color1}");
        $background->compositeImage($lefttoright, imagick::COMPOSITE_MULTIPLY, 0, 0);
        if ($image) {
            $logo = new Imagick();
            $logo->readImage(realpath($image));
            $logo->resizeImage($h, $h, imagick::FILTER_TRIANGLE, 1);
            $background->compositeImage($logo, imagick::COMPOSITE_OVER, $w - $h - $h / 3, 0);
        }
        $background->compositeImage($whiteup, imagick::COMPOSITE_SCREEN, 0, 0);
        $background->compositeImage($bottomdark, imagick::COMPOSITE_MULTIPLY, 0, $h / 2);
        $slantleft = new Imagick();
        $slantleft->newPseudoImage($h * sqrt(5) / 2, 8, "gradient:{$iglow}-white");
        $slantleft->rotateImage("none", 296.6);
        $slantright = new Imagick();
        $slantright->newPseudoImage($h * sqrt(5) / 2, 8, "gradient:{$iglow}-white");
        $slantright->rotateImage("none", 117.2);
        $top = new Imagick();
        $top->newPseudoImage($w, 8, "gradient:{$iglow}-white");
        $bottom = new Imagick();
        $bottom->newPseudoImage($w, 8, "gradient:white-{$iglow}");
        $slants = new Imagick();
        $slants->newPseudoImage($w, $h, "xc:white");
        $slants->compositeImage($slantleft, imagick::COMPOSITE_OVER, -1, 0);
        $slants->compositeImage($slantright, imagick::COMPOSITE_OVER, $w - $h / 2 - 9, 0);
        $slants->compositeImage($top, imagick::COMPOSITE_MULTIPLY, 0, 0);
        $slants->compositeImage($bottom, imagick::COMPOSITE_MULTIPLY, 0, $h - 8);
        $background->compositeImage($slants, imagick::COMPOSITE_MULTIPLY, 0, 00);
        $draw1 = new ImagickDraw();
        $draw1->pushPattern('gradient', 0, 0, $w, $h);
        $draw1->composite(Imagick::COMPOSITE_OVER, 0, 0, $w, $h, $background);
        $draw1->popPattern();
        $draw1->setFillPatternURL('#gradient');
        $draw1->polygon(array(array('x' => 00, 'y' => $h - 1), array('x' => $h / 2 - 1, 'y' => 00), array('x' => $w - 1, 'y' => 00), array('x' => $w - $h / 2 - 1, 'y' => $h - 1)));
        $points = array(array('x' => 0, 'y' => $h - 1), array('x' => $h / 2 - 1, 'y' => 00), array('x' => $w - 1, 'y' => 00), array('x' => $w - $h / 2 - 1, 'y' => $h - 1));
        for ($i = 0; $i < 4; $i++) {
            $points[$i]['x'] += 10;
            $points[$i]['y'] += 10;
        }
        $shadow = new Imagick();
        $shadow->newPseudoImage($w + 20, $h + 20, "xc:none");
        $draws = new ImagickDraw();
        $draws->setFillColor("black");
        $draws->polygon($points);
        $shadow->drawImage($draws);
        $shadow->blurImage(0, 4, imagick::CHANNEL_ALPHA);
        $im = new Imagick();
        $im->newPseudoImage($w, $h, "xc:none");
        $im->drawImage($draw1);
        $im2 = new Imagick();
        $im2->newPseudoImage($w + 50, $h + 50, "xc:none");
        $im2->compositeImage($shadow, imagick::COMPOSITE_OVER, 5, 5);
        $draw1 = new ImagickDraw();
        $draw1->setStrokeWidth(6);
        $draw1->setStrokeColor("black");
        $draw1->polygon($points);
        $draw1->setStrokeWidth(2);
        $draw1->setStrokeColor("white");
        $draw1->polygon($points);
        $im2->drawImage($draw1);
        $im2->compositeImage($im, imagick::COMPOSITE_OVER, 10, 10);
        $canvas->compositeImage($im2, imagick::COMPOSITE_OVER, $x - 10, $y - 10);
    } catch (Exception $e) {
        echo 'Error: ', $e->getMessage(), "";
    }
}
开发者ID:hamilr2,项目名称:rpits,代码行数:94,代码来源:imagick_include.php

示例10: polygon

 /**
  * {@inheritdoc}
  */
 public function polygon(array $coordinates, ColorInterface $color, $fill = false, $thickness = 1)
 {
     if (count($coordinates) < 3) {
         throw new InvalidArgumentException(sprintf('Polygon must consist of at least 3 coordinates, %d given', count($coordinates)));
     }
     $points = array_map(function (PointInterface $p) {
         return array('x' => $p->getX(), 'y' => $p->getY());
     }, $coordinates);
     try {
         $pixel = $this->getColor($color);
         $polygon = new \ImagickDraw();
         $polygon->setStrokeColor($pixel);
         $polygon->setStrokeWidth(max(1, (int) $thickness));
         if ($fill) {
             $polygon->setFillColor($pixel);
         } else {
             $polygon->setFillColor('transparent');
         }
         $polygon->polygon($points);
         $this->imagick->drawImage($polygon);
         $pixel->clear();
         $pixel->destroy();
         $polygon->clear();
         $polygon->destroy();
     } catch (\ImagickException $e) {
         throw new RuntimeException('Draw polygon operation failed', $e->getCode(), $e);
     }
     return $this;
 }
开发者ID:jmstan,项目名称:craft-website,代码行数:32,代码来源:Drawer.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)");
     // Prepare canvas for drawing main graph
     $draw = new ImagickDraw();
     $draw->setStrokeColor($color['line']);
     $draw->setFillColor($color['bg']);
     $draw->setStrokeAntialias(true);
     $draw->setStrokeWidth(2);
     // Prepare values for drawing main graph
     define('BOTTOM_PAD', 30);
     define('TOP_PAD', 25);
     define('LEFT_PAD', 43);
     define('RIGHT_PAD', 15);
     $graph = array('b' => self::HEIGHT - BOTTOM_PAD, 't' => TOP_PAD);
     $graph['height'] = $graph['b'] - $graph['t'];
     $dataHeight = $this->_max_karma - $this->_min_karma;
     if ($dataHeight != 0) {
         $graph['k'] = $graph['height'] / $dataHeight;
     } else {
         $graph['k'] = 1;
     }
     $karma = array_reverse($this->_karma);
     $graph['segmentWidth'] = (self::WIDTH - LEFT_PAD - RIGHT_PAD) / (count($karma) - 1);
     $lastX = LEFT_PAD;
     $lastY = $karma[0];
     $graph['cords'] = array();
     foreach ($karma as $y) {
         $graph['cords'][] = array('x' => (double) $lastX, 'y' => $graph['b'] - round($y - $this->_min_karma) * $graph['k']);
         $lastX += $graph['segmentWidth'];
     }
     //Draw graph
     $draw->polyline($graph['cords']);
     $this->_canvas->drawImage($draw);
     // Draw bottom bg
     define('TOP_SPACER', 10);
     $draw = new ImagickDraw();
     $draw->setFillColor($color['bottom_bg']);
     $draw->polygon(array(array('x' => 0, 'y' => $graph['b'] + TOP_SPACER), array('x' => self::WIDTH, 'y' => $graph['b'] + TOP_SPACER), array('x' => self::WIDTH, 'y' => self::HEIGHT), array('x' => 0, 'y' => self::HEIGHT)));
     $this->_canvas->drawImage($draw);
     $draw->destroy();
     // Draw texts
     $draw = new ImagickDraw();
     $draw->setTextAntialias(true);
     $draw->setFontSize(12);
     $draw->setFillColor($color['text']);
     $draw->setFont(realpath('stuff/arial.ttf'));
     $draw->annotation(2, 13, 'Хаброметр юзера');
     $draw->setFont(realpath('stuff/arialbd.ttf'));
     $code = $this->_user;
     if (strlen($code) > 25) {
         $code = substr($code, 0, 22) . '...';
     }
     $draw->annotation(125, 13, $code);
     $image = new Imagick('stuff/bg-user2.gif');
     $this->_canvas->compositeImage($image, Imagick::COMPOSITE_COPY, 109, 2, Imagick::CHANNEL_ALL);
     $image->clear();
     $image->destroy();
     $this->_canvas->drawImage($draw);
     $draw->destroy();
     $draw = new ImagickDraw();
     $draw->setFontSize(10);
     $draw->setFillColor($color['karma']);
     $draw->setFont(realpath('stuff/consola.ttf'));
     $draw->annotation(2, $graph['t'] + 5, sprintf('%01.2f', $this->_max_karma));
     $draw->annotation(2, $graph['b'] + 2, sprintf('%01.2f', $this->_min_karma));
     $draw->setFontSize(10);
     $draw->setFillColor($color['neutral']);
     $draw->setFont(realpath('stuff/consola.ttf'));
     $t = preg_split('/-|\\s|:/', $this->_logTime);
     $this->_canvas->annotateImage($draw, self::WIDTH - 3, $graph['b'] + 2, -90, $t[2] . '.' . $t[1] . '.' . substr($t[0], -2) . ' ' . $t[3] . ':' . $t[4]);
     $this->_canvas->drawImage($draw);
     $draw->destroy();
     $draw = new ImagickDraw();
     $draw->setFillColor($color['karma']);
     $text = 'min/max: ' . sprintf('%01.2f', $this->_extremums['karma_min']) . ' / ' . sprintf('%01.2f', $this->_extremums['karma_max']);
     $draw->setFontSize(12);
     $draw->setFont(realpath('stuff/consola.ttf'));
     $draw->setFillColor($color['bg']);
     $draw->annotation(3, $graph['b'] + 25, $text);
     $draw->setFillColor($color['karma']);
     $draw->annotation(2, $graph['b'] + 24, $text);
     $this->_canvas->drawImage($draw);
     $draw->destroy();
     $draw = new ImagickDraw();
     $draw->setTextAlignment(Imagick::ALIGN_RIGHT);
     $text = 'min/max: ' . sprintf('%01.2f', $this->_extremums['habraforce_min']) . ' / ' . sprintf('%01.2f', $this->_extremums['habraforce_max']);
     $draw->setFontSize(12);
     $draw->setFont(realpath('stuff/consola.ttf'));
     $draw->setFillColor($color['bg']);
     $draw->annotation(self::WIDTH - 3, $graph['b'] + 25, $text);
//.........这里部分代码省略.........
开发者ID:lknight,项目名称:habrometr,代码行数:101,代码来源:425x120.php

示例12: setStrokeMiterLimit

function setStrokeMiterLimit($strokeColor, $fillColor, $backgroundColor)
{
    $draw = new \ImagickDraw();
    $draw->setStrokeColor($strokeColor);
    $draw->setStrokeOpacity(0.6);
    $draw->setFillColor($fillColor);
    $draw->setStrokeWidth(10);
    $yOffset = 100;
    $draw->setStrokeLineJoin(\Imagick::LINEJOIN_MITER);
    for ($y = 0; $y < 3; $y++) {
        $draw->setStrokeMiterLimit(40 * $y);
        $points = [['x' => 22 * 3, 'y' => 15 * 4 + $y * $yOffset], ['x' => 20 * 3, 'y' => 20 * 4 + $y * $yOffset], ['x' => 70 * 5, 'y' => 45 * 4 + $y * $yOffset]];
        $draw->polygon($points);
    }
    $image = new \Imagick();
    $image->newImage(500, 500, $backgroundColor);
    $image->setImageFormat("png");
    $image->drawImage($draw);
    $image->setImageType(\Imagick::IMGTYPE_PALETTE);
    //TODO - this should either be everywhere or nowhere
    $image->setImageCompressionQuality(100);
    $image->stripImage();
    header("Content-Type: image/png");
    echo $image->getImageBlob();
}
开发者ID:sdmmember,项目名称:Imagick-demos,代码行数:25,代码来源:functions.php

示例13: drawPolygon

 /**
  * Method to add a polygon to the image.
  *
  * @param  array $points
  * @return \Pop\Image\Imagick
  */
 public function drawPolygon($points)
 {
     $draw = new \ImagickDraw();
     $draw->setFillColor($this->setColor($this->fillColor));
     if (null !== $this->strokeWidth) {
         $draw->setStrokeColor($this->setColor($this->strokeColor));
         $draw->setStrokeWidth(null === $this->strokeWidth ? 1 : $this->strokeWidth);
     }
     $draw->polygon($points);
     $this->resource->drawImage($draw);
     return $this;
 }
开发者ID:nicksagona,项目名称:PopPHP,代码行数:18,代码来源:Imagick.php

示例14: ProcessImgRequest

/**
 * handler for img requests
 */
function ProcessImgRequest()
{
    if ($_SERVER["REQUEST_METHOD"] == "GET") {
        $method = $_GET["method"];
        $params = explode(",", $_GET["params"]);
        $width = (int) $params[0];
        $height = (int) $params[1];
        if ($method == "placeholder") {
            $image = new Imagick();
            $image->newImage($width, $height, "#707070");
            $image->setImageFormat("png");
            $x = 0;
            $y = 0;
            $size = 40;
            $draw = new ImagickDraw();
            while ($y < $height) {
                $draw->setFillColor("#808080");
                $points = [["x" => $x, "y" => $y], ["x" => $x + $size, "y" => $y], ["x" => $x + $size * 2, "y" => $y + $size], ["x" => $x + $size * 2, "y" => $y + $size * 2]];
                $draw->polygon($points);
                $points = [["x" => $x, "y" => $y + $size], ["x" => $x + $size, "y" => $y + $size * 2], ["x" => $x, "y" => $y + $size * 2]];
                $draw->polygon($points);
                $x += $size * 2;
                if ($x > $width) {
                    $x = 0;
                    $y += $size * 2;
                }
            }
            $draw->setFillColor("#B0B0B0");
            $draw->setFontSize($width / 5);
            $draw->setFontWeight(800);
            $draw->setGravity(Imagick::GRAVITY_CENTER);
            $draw->annotation(0, 0, $width . " x " . $height);
            $image->drawImage($draw);
            header("Content-type: image/png");
            echo $image;
        } else {
            $file_name = $_GET["src"];
            $path_parts = pathinfo($file_name);
            switch ($path_parts["extension"]) {
                case "png":
                    $mime_type = "image/png";
                    break;
                case "gif":
                    $mime_type = "image/gif";
                    break;
                default:
                    $mime_type = "image/jpeg";
                    break;
            }
            $file_name = $path_parts["basename"];
            $image = ResizeImage($file_name, $method, $width, $height);
            header("Content-type: " . $mime_type);
            echo $image;
        }
    }
}
开发者ID:adrianhitulescu,项目名称:mosaico,代码行数:59,代码来源:handler.php

示例15: explode

 $method = $_GET["method"];
 $params = explode(",", $_GET["params"]);
 $width = (int) $params[0];
 $height = (int) $params[1];
 if ($method == "placeholder") {
     $image = new Imagick();
     $image->newImage($width, $height, "#707070");
     $image->setImageFormat("png");
     $x = 0;
     $y = 0;
     $size = 40;
     $draw = new ImagickDraw();
     while ($y < $height) {
         $draw->setFillColor("#808080");
         $points = [["x" => $x, "y" => $y], ["x" => $x + $size, "y" => $y], ["x" => $x + $size * 2, "y" => $y + $size], ["x" => $x + $size * 2, "y" => $y + $size * 2]];
         $draw->polygon($points);
         $points = [["x" => $x, "y" => $y + $size], ["x" => $x + $size, "y" => $y + $size * 2], ["x" => $x, "y" => $y + $size * 2]];
         $draw->polygon($points);
         $x += $size * 2;
         if ($x > $width) {
             $x = 0;
             $y += $size * 2;
         }
     }
     $draw->setFillColor("#B0B0B0");
     $draw->setFontSize($width / 5);
     $draw->setFontWeight(800);
     $draw->setGravity(Imagick::GRAVITY_CENTER);
     $draw->annotation(0, 0, $width . " x " . $height);
     $image->drawImage($draw);
     header("Content-type: image/png");
开发者ID:bwl21,项目名称:mosaico-php-backend,代码行数:31,代码来源:index.php


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