本文整理匯總了PHP中Imagick::newPseudoImage方法的典型用法代碼示例。如果您正苦於以下問題:PHP Imagick::newPseudoImage方法的具體用法?PHP Imagick::newPseudoImage怎麽用?PHP Imagick::newPseudoImage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Imagick
的用法示例。
在下文中一共展示了Imagick::newPseudoImage方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: renderDistanceEuclidian
private function renderDistanceEuclidian()
{
$canvas = new \Imagick();
$canvas->newPseudoImage(500, 300, "canvas:none");
$canvas->setImageFormat('png');
$shadow = clone $canvas;
$text = clone $canvas;
$this->drawText($text);
$this->drawText($shadow, true);
if (false) {
$highlight = $this->getSilhouette($text);
$kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_EUCLIDEAN, "1");
$highlight->morphology(\Imagick::MORPHOLOGY_DISTANCE, 1, $kernel);
$highlight->autoLevelImage();
$highlight->evaluateimage(\Imagick::EVALUATE_MULTIPLY, 0.6);
$highlight->evaluateimage(\Imagick::EVALUATE_ADD, 0.2 * \Imagick::getQuantum());
$highlight->levelImage(0.2, 1.4, 0.6);
$text->compositeimage($highlight, \Imagick::COMPOSITE_MODULATE, 0, 0);
}
if (true) {
$edge = $this->getSilhouette($text);
$kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_OCTAGON, "2");
$edge->morphology(\Imagick::MORPHOLOGY_EDGE_IN, 1, $kernel);
$edge->compositeImage($text, \Imagick::COMPOSITE_ATOP, 0, 0);
}
$canvas->compositeImage($shadow, \Imagick::COMPOSITE_COPY, 0, 0);
$canvas->compositeImage($text, \Imagick::COMPOSITE_ATOP, 0, 0);
header("Content-Type: image/png");
echo $canvas->getImageBlob();
}
示例2: fx
/**
*
* @param mixed color
* @param float opacity
*/
public function fx($color = 'black', $opacity = 0.3)
{
$this->im->setImageFormat('png');
$reflection = $this->im->clone();
$reflection->flipImage();
$gradient = new Imagick();
$gradient->newPseudoImage($reflection->getImageWidth(), $reflection->getImageHeight(), "gradient:transparent-{$color}");
$reflection->compositeImage($gradient, imagick::COMPOSITE_OVER, 0, 0);
$reflection->setImageOpacity($opacity);
$canvas = new Imagick();
$canvas->newImage($this->im->getImageWidth(), $this->im->getImageHeight() * 2, $color, "png");
$canvas->compositeImage($this->im, imagick::COMPOSITE_OVER, 0, 0);
$canvas->compositeImage($reflection, imagick::COMPOSITE_OVER, 0, $this->im->getImageHeight());
return $canvas;
}
示例3: gradientRight
function gradientRight($width, $height)
{
$imagick = new Imagick();
$imagick->newPseudoImage($width, $height, 'gradient:white-black');
$imagick->rotateImage('none', 90);
return $imagick;
}
示例4: renderImage3
public function renderImage3()
{
$gradient = new \Imagick();
$gradient->newPseudoImage(1, 256, "gradient:white-black");
$newImage = $gradient->fxImage("floor(u*10+0.5)/10");
$newImage->setimageformat('jpg');
header("Content-Type: image/jpg");
echo $newImage;
}
示例5: example4
public function example4()
{
$graphWidth = 256;
$imagick = new \Imagick();
$imagick->newPseudoImage($graphWidth, 1, 'gradient:black-white');
$arguments = array(9, -90);
$imagick->functionImage(\Imagick::FUNCTION_SINUSOID, $arguments);
$fx = "(1.0/(1.0+exp(10.0*(0.5-u)))-0.006693)*1.0092503";
$fxImage = $imagick->fxImage($fx);
fxAnalyzeImage($fxImage);
}
示例6: render
public function render()
{
//Example ImagickPixel::getColorCount
$imagick = new \Imagick();
$imagick->newPseudoImage(640, 480, "magick:logo");
$histogramElements = $imagick->getImageHistogram();
$lastColor = array_pop($histogramElements);
$color = $lastColor->getColor();
$output = sprintf("ColorCount last pixel = %d\nColor is R %d G %d B %d", $lastColor->getColorCount(), $color['r'], $color['g'], $color['b']);
return nl2br($output);
//Example end
}
示例7: draw
public function draw(OsuSignature $signature)
{
if (empty($this->hexColour)) {
$this->hexColour = $signature->getHexColour();
}
$composite = new Imagick();
$composite->newPseudoImage($this->getWidth(), $this->getHeight(), "canvas:transparent");
// Background
$draw = new ImagickDraw();
$draw->setFillColor(new ImagickPixel("#555555"));
$draw->rectangle(0, 0, $this->getWidth(), $this->getHeight());
$composite->drawImage($draw);
// Main bar
$level = $signature->getUser()['level'];
$xp = $level - floor($level);
$draw = new ImagickDraw();
$draw->setFillColor(new ImagickPixel($this->hexColour));
$draw->rectangle(0, 0, $this->getWidth() * $xp, $this->getHeight());
$composite->drawImage($draw);
// Bar end glow
$draw = new ImagickDraw();
$draw->setFillColor(new ImagickPixel('#ffffff'));
$draw->setFillOpacity(0.35);
$draw->rectangle($this->getWidth() * $xp - $this->getHeight(), 0, $this->getWidth() * $xp, $this->getHeight());
$composite->drawImage($draw);
// Text draw & metrics
$textDraw = new ImagickDraw();
$textDraw->setFillColor(new ImagickPixel('#555555'));
$textDraw->setFontSize(12);
$textDraw->setFont(ComponentLabel::FONT_DIRECTORY . ComponentLabel::FONT_REGULAR);
$textDraw->setGravity(Imagick::GRAVITY_NORTHWEST);
$metrics = $composite->queryFontMetrics($textDraw, 'lv' . floor($level));
// Text white bg
$draw = new ImagickDraw();
$draw->setFillColor(new ImagickPixel('#ffffff'));
$draw->rectangle(($this->getWidth() - $metrics['textWidth']) / 2 - 2, 0, ($this->getWidth() + $metrics['textWidth']) / 2 + 1, $this->getHeight());
$composite->drawImage($draw);
// Rounding
$roundMask = new Imagick();
$roundMask->newPseudoImage($this->getWidth(), $this->getHeight(), "canvas:transparent");
$draw = new ImagickDraw();
$draw->setFillColor(new ImagickPixel("black"));
$draw->roundRectangle(0, 0, $this->getWidth() - 1, $this->getHeight() - 1, $this->rounding, $this->rounding);
$roundMask->drawImage($draw);
$roundMask->setImageFormat('png');
$composite->compositeImage($roundMask, Imagick::COMPOSITE_DSTIN, 0, 0, Imagick::CHANNEL_ALPHA);
$signature->getCanvas()->compositeImage($composite, Imagick::COMPOSITE_DEFAULT, $this->x, $this->y);
// Level text
$signature->getCanvas()->annotateImage($textDraw, $this->x + ($this->getWidth() - $metrics['textWidth']) / 2, $this->y + ($this->getHeight() - $metrics['textHeight']) / 2 - 2, 0, 'lv' . floor($level));
}
示例8: renderCustomImage
function renderCustomImage()
{
$size = 400;
$imagick1 = new \Imagick();
//$imagick1->newPseudoImage($size, $size, 'gradient:black-white');
$imagick1->setColorspace(\Imagick::COLORSPACE_GRAY);
//$imagick1->setColorspace(\Imagick::COLORSPACE_RGB);
//$imagick1->setColorspace(\Imagick::COLORSPACE_SRGB);
$imagick1->setColorspace(\Imagick::COLORSPACE_CMYK);
$imagick1->newPseudoImage($size, $size, 'gradient:gray(100%)-gray(0%)');
$imagick1->setFormat('png');
//analyzeImage($imagick1);
header("Content-Type: image/png");
echo $imagick1->getImageBlob();
}
示例9: renderCustomImage
public function renderCustomImage()
{
$size = 200;
$imagick1 = new \Imagick();
$imagick1->newPseudoImage($size, $size, 'gradient:black-white');
$arguments = array(9, -90);
$imagick1->functionImage(\Imagick::FUNCTION_SINUSOID, $arguments);
$imagick2 = new \Imagick();
$imagick2->newPseudoImage($size, $size, 'gradient:black-white');
$arguments = array(0.5, 0);
$imagick2->functionImage(\Imagick::FUNCTION_SINUSOID, $arguments);
$imagick1->compositeimage($imagick2, \Imagick::COMPOSITE_MULTIPLY, 0, 0);
$imagick1->setimageformat('png');
header("Content-Type: image/png");
echo $imagick1->getImageBlob();
}
示例10: gameSummary
function gameSummary(&$canvas, $o)
{
$maxHeight = 910;
$width = 980;
$height = $maxHeight;
$plays = new Imagick();
$plays->newPseudoImage($width, $height, 'xc:none');
$teams = array();
$teams['V'] = fetchTeam($o['vTeam']);
$teams['H'] = fetchTeam($o['hTeam']);
$bodyHeight = 200;
$path = "http://www.sidearmstats.com/rpi/mhockey/1.xml";
$path = "sidearm.xml";
$path = $o['liveStatsXML'];
$scores = getGameSummaryInfo($path);
$vOffset = 0;
$lastPeriod = 0;
$playIndex = 0;
foreach ($scores->score as $score) {
$playIndex++;
if ($vOffset + 150 > $maxHeight && $o["numPlays"] == "auto") {
break;
} else {
if ($o["numPlays"] != "auto" && $o["numPlays"] + $o["startIndex"] < $playIndex) {
break;
}
}
if ($o["startIndex"] + 1 > $playIndex) {
continue;
}
if ($vOffset > 0) {
$plays->compositeImage(fillRectangle(960, 2, '#FFF'), imagick::COMPOSITE_OVER, 0, $vOffset);
}
if ($score['prd'] + 0 != $lastPeriod) {
$lastPeriod = $score['prd'] + 0;
$plays->compositeImage(periodLabel($lastPeriod), imagick::COMPOSITE_OVER, 0, $vOffset);
$vOffset += 50;
$plays->compositeImage(fillRectangle(960, 2, '#FFF'), imagick::COMPOSITE_OVER, 0, $vOffset);
}
$plays->compositeImage(scoringPlay($score, $teams), imagick::COMPOSITE_OVER, 0, $vOffset);
$vOffset += 100;
//print_r($score);
}
addGeoToCanvas($canvas, array('type' => 'flexBox', 'w' => 1920, 'h' => 1080, 'x' => 0, 'y' => 0, 'bodyText' => '', 'boxHeight' => $vOffset, 'boxWidth' => 1000, 'boxOffset' => 'auto', 'boxPadding' => 10, 'titleColor' => $o['barColor'], 'titleHeight' => '70', 'titleText' => $o['titleText'], 'titleGravity' => 'center', 'logoHeight' => 100, 'logoLeft' => $teams['H']['logo'], 'logoRight' => $teams['V']['logo']));
$canvas->compositeImage($plays, imagick::COMPOSITE_OVER, (1920 - 980) / 2, 1080 - 50 - $vOffset - 10);
}
示例11: a0nCRQ
function a0nCRQ($msg, $padx, $pady, $bc, $fc, $tc)
{
$im = new Imagick();
$idraw = new ImagickDraw();
$idraw->setFontSize(30);
$idraw->setFont('MyriadPro-Regular.otf');
$idraw->setGravity(Imagick::GRAVITY_CENTER);
$metrics = $im->queryFontMetrics($idraw, $msg);
$im->newPseudoImage($metrics["textWidth"] + $padx * 2, $metrics["textHeight"] + $pady * 2, "xc:none");
$idraw->setFillColor($fc);
$idraw->setStrokeColor($bc);
$idraw->roundrectangle(0, 0, $metrics["textWidth"] + $padx * 2 - 1, $metrics["textHeight"] + $pady * 2 - 1, 10, 10);
$idraw->setFillColor($tc);
$idraw->setStrokeColor($tc);
$idraw->annotation(0, 0, $msg);
$im->drawImage($idraw);
return $im;
}
示例12: renderFontEffect
function renderFontEffect()
{
$canvas = new \Imagick();
$canvas->newPseudoImage(500, 300, "canvas:none");
$canvas->setImageFormat('png');
$shadow = clone $canvas;
$text = clone $canvas;
drawText($text);
drawText($shadow, true);
$edge = getSilhouette($text);
$kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_OCTAGON, "2");
$edge->morphology(\Imagick::MORPHOLOGY_EDGE_IN, 1, $kernel);
$edge->compositeImage($text, \Imagick::COMPOSITE_ATOP, 0, 0);
$canvas->compositeImage($shadow, \Imagick::COMPOSITE_COPY, 0, 0);
$canvas->compositeImage($text, \Imagick::COMPOSITE_ATOP, 0, 0);
header("Content-Type: image/png");
echo $canvas->getImageBlob();
}
示例13: generateFavicon
public function generateFavicon()
{
$faviconConfigList = $this->_getFaviconConfigList();
$this->_getStreamOutput()->writeln('Generating favicons');
$themeDirStructList = Functional\map(CM_Site_Abstract::getAll(), function (CM_Site_Abstract $site) {
$render = new CM_Frontend_Render(new CM_Frontend_Environment($site));
return ['render' => $render, 'themeDir' => new CM_File($render->getThemeDir(true))];
});
$themeDirStructList = Functional\unique($themeDirStructList, function (array $themeDirStruct) {
/** @var CM_File $themeDir */
$themeDir = $themeDirStruct['themeDir'];
return $themeDir->getPath();
});
//filter site aliases
foreach ($themeDirStructList as $themeDirStruct) {
/** @var CM_Frontend_Render $render */
$render = $themeDirStruct['render'];
/** @var CM_File $themeDir */
$themeDir = $themeDirStruct['themeDir'];
$svgFile = $themeDir->joinPath('resource', 'img', self::FAVICON_SVG_FILENAME);
if ($svgFile->exists()) {
foreach ($faviconConfigList as $outputFilename => $config) {
$backgroundWidth = (int) $config['width'];
$backgroundHeight = (int) $config['height'];
$backgroundColor = false === $config['transparent'] ? $render->getLessVariable(self::FAVICON_BACKGROUND_LESS_VARIABLE) : 'transparent';
$background = new Imagick();
$background->newPseudoImage($backgroundWidth, $backgroundHeight, 'canvas:' . $backgroundColor);
$backgroundImage = new CM_Image_Image($background);
$iconSize = (int) (min($backgroundWidth, $backgroundHeight) * (double) $config['iconSize']);
$iconImage = CM_Image_Image::createFromSVGWithSize($svgFile->read(), $iconSize, $iconSize);
$backgroundImage->compositeImage($iconImage, ($backgroundWidth - $iconSize) / 2, ($backgroundHeight - $iconSize) / 2);
$backgroundImage->setFormat(CM_Image_Image::FORMAT_PNG);
$targetFile = $themeDir->joinPath('resource', 'img', 'meta', $outputFilename);
$targetFile->ensureParentDirectory();
$targetFile->write($backgroundImage->getBlob());
$this->_getStreamOutput()->writeln('Generated ' . $targetFile->getPath());
}
}
}
}
示例14: Imagick
<?php
$im = new Imagick();
$im->newPseudoImage(100, 100, "XC:red");
$im->setImageFormat("png");
echo $im->width . "x" . $im->height . "\n";
echo $im->format;
示例15: Imagick
<?php
$im = new Imagick();
$im->newPseudoImage(100, 100, "XC:red");
var_dump($im->getImageGeometry());
$im->newPseudoImage(0, 0, "magick:logo");
var_dump($im->getImageGeometry());
$im->readImage("magick:logo");
var_dump($im->getImageGeometry());
$im->newPseudoImage(0, 0, "rose:");
var_dump($im->getImageGeometry());
try {
$im->newPseudoImage(0, 0, "png:");
var_dump($im->getImageGeometry());
} catch (Exception $e) {
echo "fail\n";
}