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


PHP ImagickPixel::setColor方法代码示例

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


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

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

示例2: setColor

function setColor()
{
    $draw = new \ImagickDraw();
    $strokeColor = new \ImagickPixel('green');
    $fillColor = new \ImagickPixel();
    $fillColor->setColor('rgba(100%, 75%, 0%, 1.0)');
    $draw->setstrokewidth(3.0);
    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);
    $draw->rectangle(200, 200, 300, 300);
    $image = new \Imagick();
    $image->newImage(500, 500, "SteelBlue2");
    $image->setImageFormat("png");
    $image->drawImage($draw);
    header("Content-Type: image/png");
    echo $image->getImageBlob();
}
开发者ID:atawsports2,项目名称:Imagick-demos,代码行数:17,代码来源:functions.php

示例3: fnOnTheFlyImageResize

 /**
  * Function resize the Image on the fly with Imagemagick
  *
  * @param sting $strSrc
  * @param sting $intHeight
  * @param sting $intWidth
  *
  */
 function fnOnTheFlyImageResize($strSrc, $intHeight, $intWidth)
 {
     $strImageSrc = $strSrc;
     $strImageH = $intHeight;
     $strImageW = $intWidth;
     if (substr(trim($strImageSrc), 0, 4) == "http") {
         // SITENAME
         $strImageSrc = str_replace(SITE_NAME . "/", "", $strImageSrc);
         if (substr(trim($strImageSrc), 0, 4) == "user") {
             // NOT BSE64 DEODED
             $strImageSrc = base64_encode($strImageSrc);
         }
         if (substr(trim($strImageSrc), 0, 9) == "editorial") {
             // NOT BSE64 DEODED
             $strImageSrc = base64_encode($strImageSrc);
         }
     } elseif (substr(trim($strImageSrc), 0, 4) == "user") {
         // NOT BSE64 DEODED
         $strImageSrc = base64_encode($strImageSrc);
     } elseif (substr(trim($strImageSrc), 0, 5) == "/user") {
         // NOT BSE64 DEODED
         $strImageSrc = substr_replace("/", '', 0, 1);
         $strImageSrc = base64_encode($strImageSrc);
     }
     if (!$strImageH) {
         $strImageH = "70";
     }
     if (!$strImageW) {
         $strImageW = "70";
     }
     if ($strImageSrc != "") {
         // Decode image from base64
         $image = base64_decode($strImageSrc);
         //$image=$strImageSrc;
         // Create Imagick object
         $im = new Imagick();
         // Convert image into Imagick
         $im->readImage(DOCUMENT_ROOT . "/" . $image);
         //$im->readImage($image);
         // Create thumbnail max of 200x82
         $im->thumbnailImage($strImageW, $strImageH, true);
         // Add a subtle border
         $color = new ImagickPixel();
         $color->setColor("rgb(220,220,220)");
         $im->borderImage($color, 1, 1);
         // Output the image
         $output = $im->getimageblob();
         $outputtype = $im->getFormat();
         // unset($im);
         header("Content-type: {$outputtype}");
         print $output;
     }
 }
开发者ID:vikrantlabde,项目名称:marmik,代码行数:61,代码来源:clsUtil.php

示例4: transform

 public function transform($operation, $parameters)
 {
     if ($this->properties["mimetype"] == "image/tilepic") {
         return false;
     }
     # no transformations for Tilepic
     if (!$this->handle) {
         return false;
     }
     if (!$this->info["TRANSFORMATIONS"][$operation]) {
         # invalid transformation
         $this->postError(1655, _t("Invalid transformation %1", $operation), "WLPlugImagick->transform()");
         return false;
     }
     # get parameters for this operation
     $sparams = $this->info["TRANSFORMATIONS"][$operation];
     $w = $parameters["width"];
     $h = $parameters["height"];
     $cw = $this->get("width");
     $ch = $this->get("height");
     if ((bool) $this->properties['no_upsampling']) {
         $w = min($cw, round($w));
         $h = min($ch, round($h));
     }
     $do_crop = 0;
     try {
         switch ($operation) {
             # -----------------------
             case 'ANNOTATE':
                 $d = new ImagickDraw();
                 if ($parameters['font']) {
                     $d->setFont($parameters['font']);
                 }
                 $size = $parameters['size'] > 0 ? $parameters['size'] : 18;
                 $d->setFontSize($size);
                 $inset = $parameters['inset'] > 0 ? $parameters['inset'] : 0;
                 $pw = new ImagickPixel();
                 $pw->setColor($parameters['color'] ? $parameters['color'] : "black");
                 $d->setFillColor($pw);
                 switch ($parameters['position']) {
                     case 'north_east':
                         $d->setGravity(imagick::GRAVITY_NORTHEAST);
                         break;
                     case 'north_west':
                         $d->setGravity(imagick::GRAVITY_NORTHWEST);
                         break;
                     case 'north':
                         $d->setGravity(imagick::GRAVITY_NORTH);
                         break;
                     case 'south_east':
                         $d->setGravity(imagick::GRAVITY_SOUTHEAST);
                         break;
                     case 'south':
                         $d->setGravity(imagick::GRAVITY_SOUTH);
                         break;
                     case 'center':
                         $d->setGravity(imagick::GRAVITY_CENTER);
                         break;
                     case 'south_west':
                     default:
                         $d->setGravity(imagick::GRAVITY_SOUTHWEST);
                         break;
                 }
                 $this->handle->annotateImage($d, $inset, $size + $inset, 0, $parameters['text']);
                 break;
                 # -----------------------
             # -----------------------
             case 'WATERMARK':
                 if (!file_exists($parameters['image'])) {
                     break;
                 }
                 $vn_opacity_setting = $parameters['opacity'];
                 if ($vn_opacity_setting < 0 || $vn_opacity_setting > 1) {
                     $vn_opacity_setting = 0.5;
                 }
                 $d = new ImagickDraw();
                 if (($vn_watermark_width = $parameters['width']) < 10) {
                     $vn_watermark_width = $cw / 2;
                 }
                 if (($vn_watermark_height = $parameters['height']) < 10) {
                     $vn_watermark_height = $ch / 2;
                 }
                 switch ($parameters['position']) {
                     case 'north_east':
                         $vn_watermark_x = $cw - $vn_watermark_width;
                         $vn_watermark_y = 0;
                         break;
                     case 'north_west':
                         $vn_watermark_x = 0;
                         $vn_watermark_y = 0;
                         break;
                     case 'north':
                         $vn_watermark_x = ($cw - $vn_watermark_width) / 2;
                         $vn_watermark_y = 0;
                         break;
                     case 'south_east':
                         $vn_watermark_x = $cw - $vn_watermark_width;
                         $vn_watermark_y = $ch - $vn_watermark_height;
                         break;
                     case 'south':
//.........这里部分代码省略.........
开发者ID:guaykuru,项目名称:pawtucket,代码行数:101,代码来源:Imagick.php

示例5: __construct

 /**
  * Default constructor
  * @param mixed|null $files
  */
 public function __construct($files = null)
 {
     parent::__construct($files);
     $this->black = new \ImagickPixel();
     $this->black->setColor("black");
 }
开发者ID:Cherkesov,项目名称:GFB-MosaicBundle,代码行数:10,代码来源:ImagickExt.php

示例6: transform

 /**
  * Apply the transform to the sfImage object.
  *
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     $fill = new ImagickPixel();
     $fill->setColor($this->fill);
     /*
      *  colorFloodfillImage has been depricated, use new method is available
      */
     if (method_exists($resource, 'floodFillPaintImage') && is_null($this->border)) {
         $target = $resource->getImagePixelColor($this->getX(), $this->getY());
         $resource->floodFillPaintImage($fill, $this->getFuzz(), $target, $this->getX(), $this->getY(), false);
     } else {
         $border = new ImagickPixel();
         $border->setColor($this->border);
         $resource->colorFloodfillImage($fill, $this->getFuzz(), $border, $this->getX(), $this->getY());
     }
     return $image;
 }
开发者ID:thefkboss,项目名称:ZenTracker,代码行数:24,代码来源:sfImageFillImageMagick.class.php

示例7: border

 public function border($width, $height, $color = 'rgb(220, 220, 220)')
 {
     $color = new ImagickPixel();
     $color->setColor($color);
     $this->image->borderImage($color, $width, $height);
 }
开发者ID:wjyGamedev,项目名称:xuezhiweb,代码行数:6,代码来源:ImageUtil.php

示例8: transform

 /**
  * Apply the transform to the sfImage object.
  *
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     // By default use the background of the top left corner
     if (is_null($this->background)) {
         $this->background = $resource->getImagePixelColor(0, 0);
         $background = $this->background;
     } else {
         $background = new ImagickPixel();
         $background->setColor($this->background);
     }
     $resource->setBackgroundColor($background);
     $resource->trimImage($this->fuzz);
     return $image;
 }
开发者ID:GrifiS,项目名称:SyrexCMS,代码行数:21,代码来源:sfImageTrimImageMagick.class.php

示例9: setColor

 /**
  * @see	wcf\system\image\adapter\IImageAdapter::setColor()
  */
 public function setColor($red, $green, $blue)
 {
     $this->color = new \ImagickPixel();
     $this->color->setColor('rgb(' . $red . ',' . $green . ',' . $blue . ')');
 }
开发者ID:ZerGabriel,项目名称:WCF,代码行数:8,代码来源:ImagickImageAdapter.class.php

示例10: borderImage

function borderImage($im, $borderWidth)
{
    $color = new ImagickPixel();
    $color->setColor("rgb(224,224,224)");
    $im->borderImage($color, $borderWidth, $borderWidth);
    $color->destroy();
    return $im;
}
开发者ID:priyankajsr19,项目名称:indusdiva2,代码行数:8,代码来源:image_helper.php

示例11: microtime

<?php

require '../lib_config.php';
session();
$authnum = '';
srand((double) microtime() * 1000000);
$_SESSION['authcode'] = "";
/* imagick对象 */
$Imagick = new Imagick();
/* 背景对象 */
$bg = new ImagickPixel();
/* Set the pixel color to white */
$bg->setColor('rgb(235,235,235)');
/* 画刷 */
$ImagickDraw = new ImagickDraw();
/* Set font and font size. You can also specify /path/to/font.ttf */
$ImagickDraw->setFont(LIBPATH . '/../static/fonts/CONSOLA.TTF');
$ImagickDraw->setFontSize(24);
$ImagickDraw->setFillColor('black');
//生成数字和字母混合的验证码方法
$ychar = "0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z";
$list = explode(",", $ychar);
for ($i = 0; $i < 4; $i++) {
    $randnum = rand(0, 35);
    $authnum .= $list[$randnum];
}
$authnum = strtoupper($authnum);
$_SESSION['authcode'] = $authnum;
/* Create new empty image */
$Imagick->newImage(60, 24, $bg);
/* Write the text on the image */
开发者ID:zzzzzmh,项目名称:KeywordFilteringService,代码行数:31,代码来源:authcode.php

示例12: transform

 /**
  * Apply the transform to the sfImage object.
  *
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     $fill = new ImagickPixel();
     $fill->setColor($this->fill);
     $border = new ImagickPixel();
     $border->setColor($this->border);
     $resource->colorFloodfillImage($fill, $this->fuzz, $border, $this->x, $this->y);
     return $image;
 }
开发者ID:vcgato29,项目名称:poff,代码行数:16,代码来源:sfImageFillImageMagick.class.php

示例13: dump

<?php

// hphp doesn't support this at this moment
// ini_set('precision', 3);
function dump($exp)
{
    $ret = print_r($exp, true);
    $ret = preg_replace_callback('/\\d+\\.\\d+/', function ($matches) {
        return sprintf('%.3f', $matches[0]);
    }, $ret);
    echo "{$ret}\n";
}
$pixel = new ImagickPixel();
$pixel->setColor('yellow');
dump($pixel->getHSL());
dump($pixel->getColor(true));
$pixel = new ImagickPixel($pixel->getColorAsString());
dump($pixel->getHSL());
dump($pixel->getColor(false));
$pixel = new ImagickPixel();
$pixel->setHSL(0.3, 0.4, 0.5);
dump($pixel->getHSL());
dump($pixel->getColor(false));
$pixel = new ImagickPixel($pixel->getColorAsString());
dump($pixel->getHSL());
dump($pixel->getColor(true));
$pixel = new ImagickPixel('#F02B88');
$colors = array(Imagick::COLOR_BLACK, Imagick::COLOR_BLUE, Imagick::COLOR_CYAN, Imagick::COLOR_GREEN, Imagick::COLOR_RED, Imagick::COLOR_YELLOW, Imagick::COLOR_MAGENTA, Imagick::COLOR_ALPHA, Imagick::COLOR_FUZZ);
foreach ($colors as $color) {
    dump($pixel->getColorValue($color));
}
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:pixel_color.php

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

示例15: brushpng

 public function brushpng($color, $size, $brushpath)
 {
     $info = $this->_handle->getImageGeometry();
     $image = new \Imagick();
     $image->newImage($info["width"], $info["height"], "transparent", "png");
     //$image->setImageFormat("png");
     $draw = new \ImagickDraw();
     $pixel = new \ImagickPixel();
     $pixel->setColor("transparent");
     $draw->setFillColor($pixel);
     $pixel->setColor($color);
     $draw->setStrokeColor($pixel);
     $draw->setStrokeWidth($size);
     $draw->setStrokeLineCap(\imagick::LINECAP_ROUND);
     $draw->setStrokeLineJoin(\imagick::LINEJOIN_ROUND);
     $draw->polyline($brushpath);
     $image->drawImage($draw);
     $pixel->destroy();
     $draw->destroy();
     $this->_handle = $image;
 }
开发者ID:locphp,项目名称:rsf,代码行数:21,代码来源:HandleImagek.php


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