本文整理匯總了PHP中Imagick::compositeimage方法的典型用法代碼示例。如果您正苦於以下問題:PHP Imagick::compositeimage方法的具體用法?PHP Imagick::compositeimage怎麽用?PHP Imagick::compositeimage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Imagick
的用法示例。
在下文中一共展示了Imagick::compositeimage方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: analyzeImage
/**
* @param \Imagick $imagick
* @param int $graphWidth
* @param int $graphHeight
*/
public static function analyzeImage(\Imagick $imagick, $graphWidth = 255, $graphHeight = 127)
{
$sampleHeight = 20;
$border = 2;
$imagick->transposeImage();
$imagick->scaleImage($graphWidth, $sampleHeight);
$imageIterator = new \ImagickPixelIterator($imagick);
$luminosityArray = [];
foreach ($imageIterator as $row => $pixels) {
/* Loop through pixel rows */
foreach ($pixels as $column => $pixel) {
/* Loop through the pixels in the row (columns) */
/** @var $pixel \ImagickPixel */
if (false) {
$color = $pixel->getColor();
$luminosityArray[] = $color['r'];
} else {
$hsl = $pixel->getHSL();
$luminosityArray[] = $hsl['luminosity'];
}
}
/* Sync the iterator, this is important to do on each iteration */
$imageIterator->syncIterator();
break;
}
$draw = new \ImagickDraw();
$strokeColor = new \ImagickPixel('red');
$fillColor = new \ImagickPixel('red');
$draw->setStrokeColor($strokeColor);
$draw->setFillColor($fillColor);
$draw->setStrokeWidth(0);
$draw->setFontSize(72);
$draw->setStrokeAntiAlias(true);
$previous = false;
$x = 0;
foreach ($luminosityArray as $luminosity) {
$pos = $graphHeight - 1 - $luminosity * ($graphHeight - 1);
if ($previous !== false) {
/** @var $previous int */
//printf ( "%d, %d, %d, %d <br/>\n" , $x - 1, $previous, $x, $pos);
$draw->line($x - 1, $previous, $x, $pos);
}
$x += 1;
$previous = $pos;
}
$plot = new \Imagick();
$plot->newImage($graphWidth, $graphHeight, 'white');
$plot->drawImage($draw);
$outputImage = new \Imagick();
$outputImage->newImage($graphWidth, $graphHeight + $sampleHeight, 'white');
$outputImage->compositeimage($plot, \Imagick::COMPOSITE_ATOP, 0, 0);
$outputImage->compositeimage($imagick, \Imagick::COMPOSITE_ATOP, 0, $graphHeight);
$outputImage->borderimage('black', $border, $border);
$outputImage->setImageFormat("png");
App::cachingHeader("Content-Type: image/png");
echo $outputImage;
}
示例2: Imagick
function imagick_thumbnail($image, $timage, $ext, $thumbnail_name, $imginfo)
{
try {
$imagick = new Imagick();
$fullpath = "./" . $this->thumbnail_path . "/" . $timage[0] . "/" . $thumbnail_name;
if ($ext == "gif") {
$imagick->readImage($image . '[0]');
} else {
$imagick->readImage($image);
}
$info = $imagick->getImageGeometry();
$this->info[0] = $info['width'];
$this->info[1] = $info['height'];
$imagick->thumbnailImage($this->dimension, $this->dimension, true);
if ($ext == "png" || $ext == "gif") {
$white = new Imagick();
$white->newImage($this->dimension, $this->dimension, "white");
$white->compositeimage($image, Imagick::COMPOSITE_OVER, 0, 0);
$white->writeImage($fullpath);
$white->clear();
} else {
$imagick->writeImage($fullpath);
}
$imagick->clear();
} catch (Exception $e) {
echo "Unable to load image." . $e->getMessage();
return false;
}
return true;
}
示例3: getSilhouette
function getSilhouette(\Imagick $imagick)
{
$character = new \Imagick();
$character->newPseudoImage($imagick->getImageWidth(), $imagick->getImageHeight(), "canvas:white");
$canvas = new \Imagick();
$canvas->newPseudoImage($imagick->getImageWidth(), $imagick->getImageHeight(), "canvas:black");
$character->compositeimage($imagick, \Imagick::COMPOSITE_COPYOPACITY, 0, 0);
$canvas->compositeimage($character, \Imagick::COMPOSITE_ATOP, 0, 0);
$canvas->setFormat('png');
return $canvas;
}
示例4: 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();
}
示例5: createBowl
/**
*
* @param string $dishUrl
* @param int $w Width of the Output Image
* @param int $h Height of Output Image
* @return string Path of genrated Image
*/
public function createBowl($dishUrl = null, $w = 140, $h = 0)
{
$bowl = new Imagick("tmpl/img/bowl.png");
$mask = new Imagick("tmpl/img/mask.png");
$dish = new Imagick($dishUrl);
$dish->scaleimage($bowl->getimagewidth(), $bowl->getimageheight());
// Set As per bowl image
$dish->compositeimage(new Imagick("tmpl/img/mask.png"), \Imagick::COMPOSITE_COPYOPACITY, 0, 0, Imagick::CHANNEL_ALPHA);
$dish->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
$bowl->compositeimage($dish, \Imagick::COMPOSITE_ATOP, 0, 0, Imagick::CHANNEL_ALPHA);
$bowl->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
$bowl->setimageformat("jpg");
$bowl->setImageFileName($url = "img_tmp/" . $this->randomString(10) . "-GE.jpg");
// $bowl->setinterlacescheme(\Imagick::INTERLACE_PNG);
$bowl->scaleimage($w, $h);
$bowl->writeimage();
$bowl->destroy();
return $url;
}
示例6: createBowl
function createBowl($dishUrl = null, $w = 140, $h = 0)
{
$du = explode("/", $dishUrl);
$du = explode(".", $du[count($du) - 1]);
$uri = $du[count($du) - 2];
$bowl = new Imagick("img/bowl.png");
$mask = new Imagick("img/mask.png");
$dish = new Imagick($dishUrl);
$dish->scaleimage($bowl->getimagewidth(), $bowl->getimageheight());
// Set As per bowl image
$dish->compositeimage(new Imagick("img/mask.png"), \Imagick::COMPOSITE_COPYOPACITY, 0, 0, Imagick::CHANNEL_ALPHA);
$dish->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
$bowl->compositeimage($dish, \Imagick::COMPOSITE_ATOP, 0, 0, Imagick::CHANNEL_ALPHA);
$bowl->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
$bowl->setimageformat("jpg");
$bowl->setImageFileName($url = "gen/" . $uri . ".jpg");
// $bowl->setinterlacescheme(\Imagick::INTERLACE_PNG);
$bowl->scaleimage($w, $h);
$bowl->writeimage();
$bowl->destroy();
return $url;
}
示例7: getCharacterOutline
private function getCharacterOutline()
{
//Example ImagickKernel::morphology
$imagick = new \Imagick(realpath("./images/character.png"));
$character = new \Imagick();
$character->newPseudoImage($imagick->getImageWidth(), $imagick->getImageHeight(), "canvas:white");
$canvas = new \Imagick();
$canvas->newPseudoImage($imagick->getImageWidth(), $imagick->getImageHeight(), "canvas:black");
$character->compositeimage($imagick, \Imagick::COMPOSITE_COPYOPACITY, 0, 0);
$canvas->compositeimage($character, \Imagick::COMPOSITE_ATOP, 0, 0);
$canvas->setFormat('png');
return $canvas;
//Example end
}
示例8: __construct
/**
* Load up an image from a filename
*
* @param string $imgPath The path to the image to load, or null to skip
* loading the image (some other functions are available for
* populating the data). Supported graphics types depend on your PHP configuration.
*/
public function __construct($imgPath = null)
{
/* Can't use bitmaps yet */
$this->imgBmpData = null;
$this->imgRasterData = null;
if ($imgPath === null) {
// Blank image
$this->imgHeight = 0;
$this->imgWidth = 0;
$this->imgData = "";
return;
}
/* Load up using GD */
if (!file_exists($imgPath)) {
throw new Exception("File '{$imgPath}' does not exist.");
}
$ext = pathinfo($imgPath, PATHINFO_EXTENSION);
if ($ext == "bmp") {
// The plan is to implement BMP handling directly in
// PHP, as some printers understand this format themselves.
// TODO implement PHP bitmap handling
throw new Exception("Native bitmaps not yet supported. Please convert the file to a supported raster format.");
}
if ($this->isGdSupported()) {
// Prefer to use gd. It is installed by default, so
// most systems will have it, giving a consistent UX.
switch ($ext) {
case "png":
$im = @imagecreatefrompng($imgPath);
$this->readImageFromGdResource($im);
return;
case "jpg":
$im = @imagecreatefromjpeg($imgPath);
$this->readImageFromGdResource($im);
return;
case "gif":
$im = @imagecreatefromgif($imgPath);
$this->readImageFromGdResource($im);
return;
}
}
if ($this->isImagickSupported()) {
$im = new Imagick();
try {
// Throws an ImagickException if the format is not supported or file is not found
$im->readImage($imgPath);
} catch (ImagickException $e) {
// Wrap in normal exception, so that classes which call this do not themselves require imagick as a dependency.
throw new Exception($e);
}
/* Flatten by doing a composite over white, in case of transparency */
$flat = new Imagick();
$flat->newImage($im->getimagewidth(), $im->getimageheight(), "white");
$flat->compositeimage($im, Imagick::COMPOSITE_OVER, 0, 0);
$this->readImageFromImagick($flat);
return;
}
throw new Exception("Images are not supported on your PHP. Please install either the gd or imagick extension.");
}
示例9: resize
/**
* @param null $frameWidth
* @param null $frameHeight
* @throws Exception
*/
public function resize($frameWidth = null, $frameHeight = null)
{
if (empty($frameWidth) && empty($frameHeight)) {
throw new Exception('Invalid image dimensions.');
}
Varien_Profiler::start(__METHOD__);
$imagick = $this->getImageMagick();
// calculate lacking dimension
$origWidth = $imagick->getImageWidth();
$origHeight = $imagick->getImageHeight();
if ($this->keepFrame() === TRUE) {
if (null === $frameWidth) {
$frameWidth = $frameHeight;
} elseif (null === $frameHeight) {
$frameHeight = $frameWidth;
}
} else {
if (null === $frameWidth) {
$frameWidth = round($frameHeight * ($origWidth / $origHeight));
} elseif (null === $frameHeight) {
$frameHeight = round($frameWidth * ($origHeight / $origWidth));
}
}
if ($this->_keepAspectRatio && $this->_constrainOnly) {
if ($frameWidth >= $origWidth && $frameHeight >= $origHeight) {
$frameWidth = $origWidth;
$frameHeight = $origHeight;
}
}
// Resize
$imagick->setimageinterpolatemethod(imagick::INTERPOLATE_BICUBIC);
$imagick->scaleimage($frameWidth, $frameHeight, true);
// Fill desired canvas
if ($this->keepFrame() === TRUE && $frameWidth != $origWidth && $frameHeight != $origHeight) {
$composite = new Imagick();
$color = $this->_backgroundColor;
if ($color && is_array($color) && count($color) == 3) {
$bgColor = new ImagickPixel('rgb(' . implode(',', $color) . ')');
} else {
$bgColor = new ImagickPixel('white');
}
$composite->newimage($frameWidth, $frameHeight, $bgColor);
$composite->setimageformat($imagick->getimageformat());
if ($imagick->getimagecolorspace() == Imagick::COLORSPACE_CMYK) {
$profiles = $imagick->getimageprofiles('*', false);
// we're only interested if ICC profile(s) exist
$has_icc_profile = array_search('icc', $profiles) !== false;
// if it doesnt have a CMYK ICC profile, we add one
if ($has_icc_profile === false) {
$icc_cmyk = file_get_contents(__DIR__ . '/icc_profiles/USWebUncoated.icc');
$imagick->profileImage('icc', $icc_cmyk);
unset($icc_cmyk);
}
// then we add an RGB profile
$icc_rgb = file_get_contents(__DIR__ . '/icc_profiles/sRGB.icc');
$imagick->profileImage('icc', $icc_rgb);
unset($icc_rgb);
$imagick->setimagecolorspace(Imagick::COLORSPACE_SRGB);
}
$composite->setimagecolorspace($imagick->getimagecolorspace());
$dstX = floor(($frameWidth - $imagick->getimagewidth()) / 2);
$dstY = floor(($frameHeight - $imagick->getimageheight()) / 2);
$composite->compositeimage($imagick, Imagick::COMPOSITE_OVER, $dstX, $dstY);
$this->_imageHandler = $composite;
$imagick->clear();
$imagick->destroy();
}
$this->refreshImageDimensions();
Varien_Profiler::stop(__METHOD__);
}
示例10: createThali
public function createThali($dishArray = array(), $is_thali, $w = 140, $h = 0)
{
Configure::write('debug', 2);
ini_set("max_execution_time", -1);
$thali1 = new Imagick("tmpl/img/thali-1.png");
$thali2 = new Imagick("tmpl/img/thali-2.png");
$thali3 = new Imagick("tmpl/img/thali-3.png");
$mask_1 = new Imagick("tmpl/img/thali-mask2.png");
$mask_2 = new Imagick("tmpl/img/thali-mask3.png");
if (!is_array($dishArray)) {
return false;
}
$mask_cnt = 0;
foreach ($dishArray as $dish) {
if ($mask_cnt > 1) {
// Mask Locking (Modify if masks will be increased or decreased)
break;
}
$dish = new Imagick($dish);
$dish->scaleimage($thali1->getimagewidth(), $thali1->getimageheight());
// Set As per bowl image
if ($is_thali) {
if ($mask_cnt == 1) {
$dish->rotateimage("#fff", 180);
}
$dish->compositeimage(new Imagick("tmpl/img/thali-mask" . ($mask_cnt + 2) . ".png"), \Imagick::COMPOSITE_COPYOPACITY, 0, 0, Imagick::CHANNEL_ALPHA);
$dish->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
$thali1->compositeimage($dish, \Imagick::COMPOSITE_ATOP, 0, 0, Imagick::CHANNEL_ALPHA);
$thali1->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
$thali2->compositeimage($dish, \Imagick::COMPOSITE_ATOP, 0, 0, Imagick::CHANNEL_ALPHA);
$thali2->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
$thali3->compositeimage($dish, \Imagick::COMPOSITE_ATOP, 0, 0, Imagick::CHANNEL_ALPHA);
$thali3->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
} else {
$thali3 = $dish;
}
$mask_cnt++;
}
$url = "files/thali_images/" . $this->randomString(6);
$url_end = "-Thali.jpg";
$result_urls = array();
$thali1->setimageformat("jpg");
$thali1->setImageFileName($result_urls[] = $url . "-0" . $url_end);
$thali1->scaleimage($w, $h);
if ($is_thali) {
$thali2->writeimage();
}
$thali1->destroy();
$thali2->setimageformat("jpg");
$thali2->setImageFileName($result_urls[] = $url . "-1" . $url_end);
$thali2->scaleimage($w, $h);
if ($is_thali) {
$thali2->writeimage();
}
$thali2->destroy();
$thali3->setimageformat("jpg");
$thali3->setImageFileName($result_urls[] = $url . "-2" . $url_end);
$thali3->scaleimage($w, $h);
$thali3->writeimage();
$thali3->destroy();
return $result_urls;
}
示例11: renderCustomImageCreases
/**
*
*/
function renderCustomImageCreases()
{
$tshirt = new \Imagick(realpath("images/tshirt/tshirt.jpg"));
$logo = new \Imagick(realpath("images/tshirt/Logo.png"));
$logo->resizeImage(100, 100, \Imagick::FILTER_LANCZOS, 1, TRUE);
$tshirt->setImageFormat('png');
//First lets find the creases
//Get the average color of the tshirt and make a new image from it.
$colorString = getAverageColorString($tshirt);
$creases = new \Imagick();
$creases->newpseudoimage($tshirt->getImageWidth(), $tshirt->getImageHeight(), "XC:" . $colorString);
//Composite difference finds the creases
$creases->compositeimage($tshirt, \Imagick::COMPOSITE_DIFFERENCE, 0, 0);
$creases->setImageFormat('png');
//We need the image negated for the maths to work later.
$creases->negateimage(true);
//We also want "no crease" to equal 50% gray later
//$creases->brightnessContrastImage(-50, 0);
$creases->modulateImage(50, 100, 100);
//Copy the logo into an image the same size as the shirt image
//to make life easier
$logoCentre = new \Imagick();
$logoCentre->newpseudoimage($tshirt->getImageWidth(), $tshirt->getImageHeight(), "XC:none");
$logoCentre->setImageFormat('png');
$logoCentre->compositeimage($logo, \Imagick::COMPOSITE_SRCOVER, 110, 75);
//Save a copy of the tshirt sized logo
$logoCentreMask = clone $logoCentre;
//Blend the creases with the logo
$logoCentre->compositeimage($creases, \Imagick::COMPOSITE_MODULATE, 0, 0);
//Mask the logo so that only the pixels under the logo come through
$logoCentreMask->compositeimage($logoCentre, \Imagick::COMPOSITE_SRCIN, 0, 0);
//Composite the creased logo onto the shirt
$tshirt->compositeimage($logoCentreMask, \Imagick::COMPOSITE_DEFAULT, 0, 0);
//And Robert is your father's brother
header("Content-Type: image/png");
echo $tshirt->getImageBlob();
}
示例12: readImageFromImagick
/**
* Load actual image pixels from \Imagick object
*
* @param Imagick $im Image to load from
*/
public function readImageFromImagick(\Imagick $im)
{
/* Strip transparency */
$flat = new \Imagick();
$flat->newImage($im->getimagewidth(), $im->getimageheight(), "white");
$flat->compositeimage($im, \Imagick::COMPOSITE_OVER, 0, 0);
$im = $flat;
/* Threshold */
$im->setImageType(\Imagick::IMGTYPE_TRUECOLOR);
// Remove transparency (good for PDF's)
$max = $im->getQuantumRange();
$max = $max["quantumRangeLong"];
$im->thresholdImage(0.5 * $max);
/* Make a string of 1's and 0's */
$geometry = $im->getimagegeometry();
$this->imgHeight = $im->getimageheight();
$this->imgWidth = $im->getimagewidth();
$this->imgData = str_repeat("", $this->imgHeight * $this->imgWidth);
for ($y = 0; $y < $this->imgHeight; $y++) {
for ($x = 0; $x < $this->imgWidth; $x++) {
/* Faster to average channels, blend alpha and negate the image here than via filters (tested!) */
$cols = $im->getImagePixelColor($x, $y);
$cols = $cols->getcolor();
$greyness = (int) (($cols['r'] + $cols['g'] + $cols['b']) / 3) >> 7;
// 1 for white, 0 for black
$this->imgData[$y * $this->imgWidth + $x] = 1 - $greyness;
// 1 for black, 0 for white
}
}
}
示例13: genImgRunner
private function genImgRunner($rugpngs, $colors = array(), $location = "files/temp/")
{
if (is_file($location . "runner.png")) {
return $location;
}
ini_set("max_execution_time", -1);
$layers = array();
$bg = null;
foreach ($rugpngs as $rp) {
if ($rp['type'] == "LAYER") {
$layers[] = new Imagick($rp['path']);
} else {
$bg = new Imagick($rp['path']);
}
}
if ($bg == NULL) {
$bg = new Imagick();
$bg->newImage(910, 475, new ImagickPixel('none'));
$bg->setimageformat('png');
}
foreach ($layers as $layer) {
//$layer->resizeImage(910, 475, Imagick::FILTER_LANCZOS, 1, TRUE);
$layer->setimageformat("png");
}
$bg->resizeImage($layer->getimagewidth(), $layer->getimageheight(), Imagick::FILTER_LANCZOS, 1, TRUE);
$bg->setimageformat("png");
$cnt_a = 0;
foreach ($layers as $layer) {
$layer->paintopaqueimage(new ImagickPixel('#000'), $colors[$cnt_a], 900000);
$bg->compositeimage($layer, \Imagick::COMPOSITE_MULTIPLY, 0, 0);
$cnt_a++;
$layer->destroy();
}
$bg->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
$bg = $this->getBgPresp($bg, 60);
$rnd = new Imagick("files/templates/new/runner/angle.png");
$bg->scaleimage(0, $rnd->getimageheight());
$rnd->compositeimage($bg, \Imagick::COMPOSITE_MULTIPLY, 0, 0);
$rnd->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
$rnd->compositeimage(new Imagick("files/templates/new/runner/angle_trim.png"), \Imagick::COMPOSITE_COPYOPACITY, 0, 0, Imagick::CHANNEL_ALPHA);
$rnd->setimageformat("png");
$rnd->setImageFileName($location . "runner.png");
$rnd->setinterlacescheme(\Imagick::INTERLACE_PNG);
$rnd->scaleimage(733, 0);
$rnd->writeimage();
$rnd->destroy();
$rnd = new Imagick("files/templates/new/runner/flip.png");
$bg->scaleimage(0, $rnd->getimageheight());
$rnd->compositeimage($bg, \Imagick::COMPOSITE_MULTIPLY, 0, 0);
$rnd->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
$rnd->compositeimage(new Imagick("files/templates/new/runner/flip_trim.png"), \Imagick::COMPOSITE_COPYOPACITY, 0, 0, Imagick::CHANNEL_ALPHA);
$rnd->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
$rnd->compositeimage(new Imagick("files/templates/new/runner/flip.png"), \Imagick::COMPOSITE_DSTOVER, 0, 0, Imagick::CHANNEL_ALPHA);
$rnd->setimageformat("png");
$rnd->setImageFileName($location . "runner1.png");
$rnd->setinterlacescheme(\Imagick::INTERLACE_PNG);
$rnd->scaleimage(733, 0);
$rnd->writeimage();
$rnd->destroy();
$rnd = new Imagick("files/templates/new/runner/straight.png");
$bg->scaleimage($rnd->getimagewidth(), 0);
$rnd->compositeimage($bg, \Imagick::COMPOSITE_MULTIPLY, 0, 0);
$rnd->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
$rnd->compositeimage(new Imagick("files/templates/new/runner/straight_trim.png"), \Imagick::COMPOSITE_COPYOPACITY, 0, 0, Imagick::CHANNEL_ALPHA);
$rnd->setimageformat("png");
$rnd->setImageFileName($location . "runner2.png");
$rnd->setinterlacescheme(\Imagick::INTERLACE_PNG);
$rnd->scaleimage(733, 0);
$rnd->writeimage();
$rnd->destroy();
/*
$rnd = new Imagick("files/templates/runner/runners-4.png");
$rnd->compositeimage($bg, \Imagick::COMPOSITE_MULTIPLY, 0, 200);
$rnd->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
$rnd->compositeimage(new Imagick("files/templates/runner/runners-4.png"), \Imagick::COMPOSITE_COPYOPACITY, 0, 0, Imagick::CHANNEL_ALPHA);
$rnd->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
$rnd->compositeimage(new Imagick("files/templates/runner/runners-5.png"), \Imagick::COMPOSITE_DEFAULT, 0, 0, Imagick::CHANNEL_ALPHA);
$rnd->setimageformat("png");
$rnd->setImageFileName($location . "runner3.png");
$rnd->writeimage();
$rnd->destroy();
*/
return $location;
}
示例14: createThali
public function createThali($dishArray = array(), $w = 140, $h = 0)
{
Configure::write('debug', 2);
ini_set("max_execution_time", -1);
$thali = new Imagick("tmpl/img/thali.png");
$mask_1 = new Imagick("tmpl/img/thali-mask1.png");
$mask_2 = new Imagick("tmpl/img/thali-mask2.png");
$mask_3 = new Imagick("tmpl/img/thali-mask3.png");
$mask_4 = new Imagick("tmpl/img/thali-mask4.png");
$mask_5 = new Imagick("tmpl/img/thali-mask5.png");
if (!is_array($dishArray)) {
return false;
}
$mask_cnt = 0;
foreach ($dishArray as $dish) {
if ($mask_cnt > 4) {
// Mask Locking (Modify if masks will be increased or decreased)
break;
}
$dish = new Imagick($dish);
if ($mask_cnt + 1 == 5) {
$dish = new Imagick("tmpl/dishes/rice.jpg");
// Fixed Rice for Mask No. 1
}
$dish->scaleimage($thali->getimagewidth(), $thali->getimageheight());
// Set As per bowl image
$dish->compositeimage(new Imagick("tmpl/img/thali-mask" . ($mask_cnt + 1) . ".png"), \Imagick::COMPOSITE_COPYOPACITY, 0, 0, Imagick::CHANNEL_ALPHA);
$dish->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
$thali->compositeimage($dish, \Imagick::COMPOSITE_ATOP, 0, 0, Imagick::CHANNEL_ALPHA);
$thali->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
$mask_cnt++;
}
$thali->setimageformat("jpg");
$thali->setImageFileName($url = "files/thali_images/" . $this->randomString(6) . "-Thali.jpg");
// $thali->setinterlacescheme(\Imagick::INTERLACE_PNG);
$thali->scaleimage($w, $h);
$thali->writeimage();
$thali->destroy();
return $url;
}
示例15: generatePoolWall
public function generatePoolWall($color, $darken, $hue, $saturation)
{
$this->setColor($color);
$this->setDarkenValue($darken);
$this->setHueSaturationValue($hue, $saturation);
$baseWall = new Imagick($this->wallImage);
$wall = $this->colorizeWall();
$baseWall->compositeimage($wall, Imagick::COMPOSITE_DEFAULT, 0, 0);
$wall->clear();
return $baseWall;
}