本文整理匯總了PHP中ImagickDraw::setfillopacity方法的典型用法代碼示例。如果您正苦於以下問題:PHP ImagickDraw::setfillopacity方法的具體用法?PHP ImagickDraw::setfillopacity怎麽用?PHP ImagickDraw::setfillopacity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ImagickDraw
的用法示例。
在下文中一共展示了ImagickDraw::setfillopacity方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: setColorspaceToRGB
/**
* @return $this
*/
public function setColorspaceToRGB()
{
$imageColorspace = $this->resource->getImageColorspace();
if ($imageColorspace == \Imagick::COLORSPACE_CMYK) {
if (self::getCMYKColorProfile() && self::getRGBColorProfile()) {
$profiles = $this->resource->getImageProfiles('*', false);
// we're only interested if ICC profile(s) exist
$has_icc_profile = array_search('icc', $profiles) !== false;
// if it doesn't have a CMYK ICC profile, we add one
if ($has_icc_profile === false) {
$this->resource->profileImage('icc', self::getCMYKColorProfile());
}
// then we add an RGB profile
$this->resource->profileImage('icc', self::getRGBColorProfile());
$this->resource->setImageColorspace(\Imagick::COLORSPACE_SRGB);
// we have to use SRGB here, no clue why but it works
} else {
$this->resource->setImageColorspace(\Imagick::COLORSPACE_SRGB);
}
} else {
if ($imageColorspace == \Imagick::COLORSPACE_GRAY) {
$this->resource->setImageColorspace(\Imagick::COLORSPACE_SRGB);
} else {
if (!in_array($imageColorspace, array(\Imagick::COLORSPACE_RGB, \Imagick::COLORSPACE_SRGB))) {
$this->resource->setImageColorspace(\Imagick::COLORSPACE_SRGB);
} else {
// this is to handle embedded icc profiles in the RGB/sRGB colorspace
$profiles = $this->resource->getImageProfiles('*', false);
$has_icc_profile = array_search('icc', $profiles) !== false;
if ($has_icc_profile) {
try {
// if getImageColorspace() says SRGB but the embedded icc profile is CMYK profileImage() will throw an exception
$this->resource->profileImage('icc', self::getRGBColorProfile());
} catch (\Exception $e) {
\Logger::warn($e);
}
}
}
}
}
// this is a HACK to force grayscale images to be real RGB - truecolor, this is important if you want to use
// thumbnails in PDF's because they do not support "real" grayscale JPEGs or PNGs
// problem is described here: http://imagemagick.org/Usage/basics/#type
// and here: http://www.imagemagick.org/discourse-server/viewtopic.php?f=2&t=6888#p31891
$currentLocale = setlocale(LC_ALL, "0");
// this locale hack thing is also a hack for imagick
setlocale(LC_ALL, "");
// details see https://www.pimcore.org/issues/browse/PIMCORE-2728
$draw = new \ImagickDraw();
$draw->setFillColor("#ff0000");
$draw->setfillopacity(0.01);
$draw->point(floor($this->getWidth() / 2), floor($this->getHeight() / 2));
// place it in the middle of the image
$this->resource->drawImage($draw);
setlocale(LC_ALL, $currentLocale);
// see setlocale() above, for details ;-)
return $this;
}
示例2: colorizeWall
private function colorizeWall()
{
$wall = new Imagick($this->wallImage);
$im = new Imagick();
$im->newimage(1280, 720, $this->baseColor, 'png');
$wall->compositeimage($im, Imagick::COMPOSITE_MULTIPLY, 0, 0);
$im->clear();
// darken image
if ($this->darkenValue < 100 && $this->darkenValue >= 50) {
$wallAdjust = clone $wall;
$wallAdjust->modulateimage($this->darkenValue, 100, 100);
$wall->compositeimage($wallAdjust, Imagick::COMPOSITE_MULTIPLY, 0, 0);
$wallAdjust->clear();
}
// lighten image
if ($this->lightenValue > 0) {
$wallAdjust = clone $wall;
$draw = new ImagickDraw();
$draw->setFillColor('#ffffff');
$draw->setfillopacity($this->lightenValue / 100);
$geometry = $wallAdjust->getImageGeometry();
$width = $geometry['width'];
$height = $geometry['height'];
$draw->rectangle(0, 0, $width, $height);
$wallAdjust->drawImage($draw);
$wall->compositeimage($wallAdjust, Imagick::COMPOSITE_DEFAULT, 0, 0);
$wallAdjust->clear();
}
// apply hue/saturation
$wall->modulateimage(100, $this->saturationValue, $this->hueValue);
$wall->compositeimage($this->mask, Imagick::COMPOSITE_DSTIN, 0, 0);
return $wall;
}
示例3: getDrawForText
/**
* 獲取文字的描繪對象
* @param string $font 字體名稱或字體路徑
* @param integer $size 字體大小
* @param string | ImagickPixel $color 字顏色
* @param float $opacity 文字的透明度,取值範圍0(全透明)-1(不透明)
* @param string | ImagickPixel $underColor 字的背景顏色
* @return ImagickDraw | false
*/
public function getDrawForText($font = null, $size = 8, $color = 'transparent', $opacity = 0.58, $underColor = null)
{
$draw = new ImagickDraw();
// $draw->setGravity(Imagick::GRAVITY_CENTER);
// 特別注意這裏了,如果這裏設置了文字水印的位置的話,那麽在其寫入別到文件時就會起作用,且其他設置的坐標都沒有用
if ($font !== null) {
if (is_file($font)) {
$draw->setfont($font);
} else {
$this->_error = '字體文件不存在';
return false;
}
}
$draw->setfontsize($size);
$draw->setFillColor($color);
$draw->setfillopacity($opacity);
// 貌似和這個是一樣的: $draw->setFillAlpha(0.5);
if ($underColor !== null) {
$draw->settextundercolor($underColor);
}
// $draw->settextalignment(2); //文字對齊方式,2為居中
return $draw;
}
示例4: applyColorProfiles
/**
* this is to force RGB and to apply custom icc color profiles
*/
protected function applyColorProfiles()
{
if ($this->resource->getImageColorspace() == Imagick::COLORSPACE_CMYK) {
if (self::getCMYKColorProfile() && self::getRGBColorProfile()) {
$profiles = $this->resource->getImageProfiles('*', false);
// we're only interested if ICC profile(s) exist
$has_icc_profile = array_search('icc', $profiles) !== false;
// if it doesn't have a CMYK ICC profile, we add one
if ($has_icc_profile === false) {
$this->resource->profileImage('icc', self::getCMYKColorProfile());
}
// then we add an RGB profile
$this->resource->profileImage('icc', self::getRGBColorProfile());
$this->resource->setImageColorspace(Imagick::COLORSPACE_RGB);
}
}
// this is a HACK to force grayscale images to be real RGB - truecolor, this is important if you want to use
// thumbnails in PDF's because they do not support "real" grayscale JPEGs or PNGs
// problem is described here: http://imagemagick.org/Usage/basics/#type
// and here: http://www.imagemagick.org/discourse-server/viewtopic.php?f=2&t=6888#p31891
if ($this->resource->getimagetype() == Imagick::IMGTYPE_GRAYSCALE) {
$draw = new ImagickDraw();
$draw->setFillColor("red");
$draw->setfillopacity(0.001);
$draw->point(0, 0);
$this->resource->drawImage($draw);
}
}
示例5: fillCircle
/**
* Draw filled circle on current image
*
* @param string $color
* @param int $center_x
* @param int $center_y
* @param int $radius
* @param float $opacity
*
* @return image
*/
public function fillCircle($color, $center_x, $center_y, $radius, $opacity = 1)
{
$fill = new \ImagickDraw();
$fill->setfillcolor(new \ImagickPixel($color));
$fill->setfillopacity($opacity);
$fill->ellipse($center_x, $center_y, $radius, $radius, 0, 360);
$this->imagick->drawimage($fill);
return $this;
}
示例6: composite
function composite($strokeColor, $fillColor, $backgroundColor)
{
$draw = new \ImagickDraw();
$draw->setStrokeColor($strokeColor);
$draw->setFillColor($fillColor);
$draw->setFillOpacity(1);
$draw->setStrokeWidth(2);
$draw->setFontSize(72);
$draw->setStrokeOpacity(1);
$draw->setStrokeColor($strokeColor);
$draw->setStrokeWidth(2);
$draw->setFont("../fonts/CANDY.TTF");
$draw->setFontSize(140);
$draw->rectangle(0, 0, 1000, 300);
$draw->setFillColor('white');
$draw->setfillopacity(1);
$draw->annotation(50, 180, "Lorem Ipsum!");
// $imagick = new \Imagick(realpath("../images/TestImage.jpg"));
// $draw->composite(\Imagick::COMPOSITE_MULTIPLY, -500, -200, 2000, 600, $imagick);
//$imagick->compositeImage($draw, 0, 0, 1000, 500);
//$draw->composite(Imagick::COMPOSITE_COLORBURN, -500, -200, 2000, 600, $imagick);
//Create an image object which the draw commands can be rendered into
$imagick = new \Imagick();
$imagick->newImage(1000, 302, $backgroundColor);
$imagick->setImageFormat("png");
//Render the draw commands in the ImagickDraw object
//into the image.
$imagick->drawImage($draw);
//Send the image to the browser
header("Content-Type: image/png");
echo $imagick->getImageBlob();
}
示例7: setColorspaceToRGB
/**
* @return $this
*/
public function setColorspaceToRGB()
{
$imageColorspace = $this->resource->getImageColorspace();
if ($imageColorspace == \Imagick::COLORSPACE_CMYK) {
if (self::getCMYKColorProfile() && self::getRGBColorProfile()) {
$profiles = $this->resource->getImageProfiles('*', false);
// we're only interested if ICC profile(s) exist
$has_icc_profile = array_search('icc', $profiles) !== false;
// if it doesn't have a CMYK ICC profile, we add one
if ($has_icc_profile === false) {
$this->resource->profileImage('icc', self::getCMYKColorProfile());
}
// then we add an RGB profile
$this->resource->profileImage('icc', self::getRGBColorProfile());
$this->resource->setImageColorspace(\Imagick::COLORSPACE_SRGB);
// we have to use SRGB here, no clue why but it works
} else {
$this->resource->setImageColorspace(\Imagick::COLORSPACE_SRGB);
}
} else {
if ($imageColorspace == \Imagick::COLORSPACE_GRAY) {
$this->resource->setImageColorspace(\Imagick::COLORSPACE_SRGB);
} else {
if (!in_array($imageColorspace, array(\Imagick::COLORSPACE_RGB, \Imagick::COLORSPACE_SRGB))) {
$this->resource->setImageColorspace(\Imagick::COLORSPACE_SRGB);
} else {
// this is to handle embedded icc profiles in the RGB/sRGB colorspace
$profiles = $this->resource->getImageProfiles('*', false);
$has_icc_profile = array_search('icc', $profiles) !== false;
if ($has_icc_profile) {
$this->resource->profileImage('icc', self::getRGBColorProfile());
}
}
}
}
// this is a HACK to force grayscale images to be real RGB - truecolor, this is important if you want to use
// thumbnails in PDF's because they do not support "real" grayscale JPEGs or PNGs
// problem is described here: http://imagemagick.org/Usage/basics/#type
// and here: http://www.imagemagick.org/discourse-server/viewtopic.php?f=2&t=6888#p31891
$draw = new \ImagickDraw();
$draw->setFillColor("#ff0000");
$draw->setfillopacity(0.01);
$draw->point(floor($this->getWidth() / 2), floor($this->getHeight() / 2));
// place it in the middle of the image
$this->resource->drawImage($draw);
return $this;
}
示例8: _text
protected function _text($text, $offset_x, $offset_y, $opacity, $r, $g, $b, $size, $fontfile)
{
$opacity = $opacity / 100;
$draw = new \ImagickDraw();
$color = sprintf("rgb(%d, %d, %d)", $r, $g, $b);
$pixel = new \ImagickPixel($color);
$draw->setFillColor($pixel);
if ($fontfile) {
$draw->setFont($fontfile);
}
if ($size) {
$draw->setFontSize($size);
}
if ($opacity) {
$draw->setfillopacity($opacity);
}
if ($offset_x < 0) {
$offset_x = abs($offset_x);
if ($offset_y < 0) {
$offset_y = abs($offset_y);
$gravity = constant("Imagick::GRAVITY_SOUTHEAST");
} else {
$gravity = constant("Imagick::GRAVITY_NORTHEAST");
}
} else {
/*
* if (y < 0 { where y comes from??
* $offset_y = abs(offset_y);
* $gravity = constant("Imagick::GRAVITY_SOUTHWEST");
* } else {
* $gravity = constant("Imagick::GRAVITY_NORTHWEST");
* }
*/
}
$draw->setGravity($gravity);
$this->_image->setIteratorIndex(0);
while (true) {
$this->_image->annotateImage($draw, $offset_x, $offset_y, 0, $text);
if (!$this->_image->nextImage()) {
break;
}
}
$draw->destroy();
}