public function renderImage() { //Create a ImagickDraw object to draw into. $draw = new \ImagickDraw(); $darkColor = new \ImagickPixel('brown'); //http://www.imagemagick.org/Usage/compose/#compose_terms $draw->setStrokeColor($darkColor); $draw->setFillColor('white'); $draw->setStrokeWidth(2); $draw->setFontSize(72); $draw->setStrokeOpacity(1); $draw->setStrokeColor($darkColor); $draw->setStrokeWidth(2); $draw->setFont("../fonts/CANDY.TTF"); $draw->setFontSize(140); $draw->setFillColor('none'); $draw->rectangle(0, 0, 1000, 300); $draw->setFillColor('white'); $draw->annotation(50, 180, "Lorem Ipsum!"); $imagick = new \Imagick(realpath("images/TestImage.jpg")); $draw->composite(\Imagick::COMPOSITE_MULTIPLY, -500, -200, 2000, 600, $imagick); //Create an image object which the draw commands can be rendered into $imagick = new \Imagick(); $imagick->newImage(1000, 300, "SteelBlue2"); $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(); }
public function makeImageOfCertification() { date_default_timezone_set('UTC'); $timeStamp = date('jS F Y'); $text = "CERTIFIED COPY" . "\n" . $this->serial . "\n" . $timeStamp; $image = new \Imagick(); $draw = new \ImagickDraw(); $color = new \ImagickPixel('#000000'); $background = new \ImagickPixel("rgb(85, 196, 241)"); $draw->setFont($this->container->getParameter('assetic.write_to') . $this->container->get('templating.helper.assets')->getUrl('fonts/futura.ttf')); $draw->setFontSize(24); $draw->setFillColor($color); $draw->setTextAntialias(true); $draw->setStrokeAntialias(true); //Align text to the center of the background $draw->setTextAlignment(\Imagick::ALIGN_CENTER); //Get information of annotation image $metrics = $image->queryFontMetrics($draw, $text); //Calc the distance(pixels) to move the sentences $move = $metrics['textWidth'] / 2; $draw->annotation($move, $metrics['ascender'], $text); //Create an image of certification $image->newImage($metrics['textWidth'], $metrics['textHeight'], $background); $image->setImageFormat('png'); $image->drawImage($draw); //Save an image temporary $image->writeImage("cert_" . $this->serial . "_.png"); }
/** * Creates a new Label component. * * @param OsuSignature $signature The base signature * @param int $x The X position of this label * @param int $y The Y position of this label * @param string $text The text of this label * @param string $font The font to use for this label; can be a string or the constants defined in {@link ComponentLabel} * @param string $colour The colour of the text of the label * @param int $fontSize The size of the font of the label * @param int $textAlignment The text alignment * @param int $width Width of the label, set to -1 to use the text size, anything bigger can be used to spoof the component system. -2 makes the component sizeless * @param int $height Height of the label, set to -1 to use the text size, anything bigger can be used to spoof the component system */ public function __construct(OsuSignature $signature, $x = 0, $y = 0, $text, $font = self::FONT_REGULAR, $colour = '#555555', $fontSize = 14, $textAlignment = Imagick::ALIGN_UNDEFINED, $width = -1, $height = -1) { parent::__construct($signature, $x, $y); $this->text = $text; $this->font = $font; $this->colour = $colour; $this->fontSize = $fontSize; $this->textAlignment = $textAlignment; $this->width = $width; $this->height = $height; $this->drawSettings = new ImagickDraw(); $this->drawSettings->setFont(self::FONT_DIRECTORY . $font); $this->drawSettings->setFontSize($fontSize); $this->drawSettings->setTextAlignment($textAlignment); $this->drawSettings->setFillColor($colour); $this->usesSpace = $width != -2; if ($width <= -1 || $height <= -1) { $tempImg = new Imagick(); $metrics = $tempImg->queryFontMetrics($this->drawSettings, $this->text); $this->width = $width <= -1 ? $metrics['textWidth'] : $width; // yeah i have to do some bullshit $this->actualWidth = $metrics['textWidth']; $this->height = $metrics['boundingBox']['y2'] - $this->y; } }
/** * 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); }
private function generateImage() { $this->generatedImage = new \Imagick(); $rgbBackgroundColor = $this->getBackgroundColor(); if (null === $rgbBackgroundColor) { $background = 'none'; } else { $background = new \ImagickPixel("rgb({$rgbBackgroundColor['0']},{$rgbBackgroundColor['1']},{$rgbBackgroundColor['2']})"); } $this->generatedImage->newImage($this->pixelRatio * 5, $this->pixelRatio * 5, $background, 'png'); // prepare color $rgbColor = $this->getColor(); $color = new \ImagickPixel("rgb({$rgbColor['0']},{$rgbColor['1']},{$rgbColor['2']})"); $draw = new \ImagickDraw(); $draw->setFillColor($color); // draw the content foreach ($this->getArrayOfSquare() as $lineKey => $lineValue) { foreach ($lineValue as $colKey => $colValue) { if (true === $colValue) { $draw->rectangle($colKey * $this->pixelRatio, $lineKey * $this->pixelRatio, ($colKey + 1) * $this->pixelRatio, ($lineKey + 1) * $this->pixelRatio); } } } $this->generatedImage->drawImage($draw); return $this; }
/** * @param ImageInterface $image * @return Image */ public function draw($image) { // Localize vars $width = $image->getWidth(); $height = $image->getHeight(); $imagick = $image->getCore(); $draw = new \ImagickDraw(); $strokeColor = new \ImagickPixel($this->getColor()->getHexString()); $fillColor = new \ImagickPixel('rgba(0,0,0,0)'); $draw->setStrokeOpacity(1); $draw->setStrokeColor($strokeColor); $draw->setFillColor($fillColor); list($x1, $y1) = $this->point1; list($x2, $y2) = $this->control; list($x3, $y3) = $this->point2; $draw->pathStart(); $draw->pathMoveToAbsolute($x1, $y1); $draw->pathCurveToQuadraticBezierAbsolute($x2, $y2, $x3, $y3); $draw->pathFinish(); // Render the draw commands in the ImagickDraw object $imagick->drawImage($draw); $type = $image->getType(); $file = $image->getImageFile(); return new Image($imagick, $file, $width, $height, $type); // Create new image with updated core }
function page_testfonts() { //load background $im = new Imagick(); $im->newimage(800, 10000, 'lightgray'); $y = 10; $i = 1; foreach ($im->queryFonts() as $font) { $insert_image = new Imagick(); $insert_image->newImage(600, 30, 'whitesmoke'); $insert_image->setImageFormat("png"); $draw = new ImagickDraw(); $draw->setFont($font); $draw->setFontSize(25); $draw->setFillColor(new ImagickPixel('black')); $draw->setgravity(imagick::GRAVITY_NORTH); $insert_image->annotateImage($draw, 0, 0, 0, $i . '.' . $font); $im->compositeImage($insert_image, $insert_image->getImageCompose(), 100, $y); $y += 30; $i++; } $im->setImageFormat('jpg'); header('Content-Type: image/jpg'); echo $im; }
/** * Draws the background colour for the signature. * Note that this has no relation to {@link Card}s. * * @param $hexColour string Hexadecimal colour value */ protected function drawBackground($hexColour) { $background = new ImagickDraw(); $background->setFillColor($hexColour); $background->rectangle(0, 0, $this->canvas->getImageWidth(), $this->canvas->getImageHeight()); $this->canvas->drawImage($background); }
function writeText($text) { if ($this->printer == null) { throw new LogicException("Not attached to a printer."); } if ($text == null) { return; } $text = trim($text, "\n"); /* Create Imagick objects */ $image = new \Imagick(); $draw = new \ImagickDraw(); $color = new \ImagickPixel('#000000'); $background = new \ImagickPixel('white'); /* Create annotation */ //$draw -> setFont('Arial');// (not necessary?) $draw->setFontSize(24); // Size 21 looks good for FONT B $draw->setFillColor($color); $draw->setStrokeAntialias(true); $draw->setTextAntialias(true); $metrics = $image->queryFontMetrics($draw, $text); $draw->annotation(0, $metrics['ascender'], $text); /* Create image & draw annotation on it */ $image->newImage($metrics['textWidth'], $metrics['textHeight'], $background); $image->setImageFormat('png'); $image->drawImage($draw); //$image -> writeImage("test.png"); /* Save image */ $escposImage = new EscposImage(); $escposImage->readImageFromImagick($image); $size = Printer::IMG_DEFAULT; $this->printer->bitImage($escposImage, $size); }
/** * Draws an ellipse on the handle * * @param ImageMagick-object $handle The handle on which the ellipse is drawn * @param Zend_Image_Action_DrawEllipse $ellipseObject The object that with all info */ public function perform(Zend_Image_Adapter_ImageMagick $adapter, Zend_Image_Action_DrawEllipse $ellipseObject) { $draw = new ImagickDraw(); $strokeColor = (string) $ellipseObject->getStrokeColor(); $strokeAlpha = $ellipseObject->getStrokeAlpha() * 0.01; $draw->setStrokeColor($strokeColor); $draw->setStrokeOpacity($strokeAlpha); $draw->setStrokeWidth($ellipseObject->getStrokeWidth()); $strokeDashArray = $ellipseObject->getStrokeDashPattern(); if (count($strokeDashArray) > 0) { $draw->setStrokeDashArray($strokeDashArray); } $draw->setStrokeDashOffset($ellipseObject->getStrokeDashOffset()); if ($ellipseObject->filled()) { $fillColor = (string) $ellipseObject->getFillColor(); $draw->setFillColor($fillColor); $draw->setFillOpacity($ellipseObject->getFillAlpha() * 0.01); } else { $draw->setFillOpacity(0); } $width = $ellipseObject->getWidth(); $height = $ellipseObject->getHeight(); $x = $ellipseObject->getLocation()->getX(); $y = $ellipseObject->getLocation()->getY(); $draw->ellipse($x, $y, $width / 2, $height / 2, 0, 360); $adapter->getHandle()->drawImage($draw); }
private static function image($frame, $pixelPerPoint = 4, $outerFrame = 4, $format = "png", $quality = 85, $filename = FALSE, $save = TRUE, $print = false) { $imgH = count($frame); $imgW = strlen($frame[0]); $col[0] = new \ImagickPixel("white"); $col[1] = new \ImagickPixel("black"); $image = new \Imagick(); $image->newImage($imgW, $imgH, $col[0]); $image->setCompressionQuality($quality); $image->setImageFormat($format); $draw = new \ImagickDraw(); $draw->setFillColor($col[1]); for ($y = 0; $y < $imgH; $y++) { for ($x = 0; $x < $imgW; $x++) { if ($frame[$y][$x] == '1') { $draw->point($x, $y); } } } $image->drawImage($draw); $image->borderImage($col[0], $outerFrame, $outerFrame); $image->scaleImage(($imgW + 2 * $outerFrame) * $pixelPerPoint, 0); if ($save) { if ($filename === false) { throw new Exception("QR Code filename can't be empty"); } $image->writeImages($filename, true); } if ($print) { Header("Content-type: image/" . $format); echo $image; } }
/** * Flood the image with a color fill. * * @param int $r * @param int $g * @param int $b * @return Imagick */ public function fill($r, $g, $b) { $draw = new \ImagickDraw(); $draw->setFillColor($this->image->getColor([(int) $r, (int) $g, (int) $b])); $draw->rectangle(0, 0, $this->image->getWidth(), $this->image->getHeight()); $this->image->resource()->drawImage($draw); return $this; }
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)"); $color['habr'] = new ImagickPixel("rgb(83, 121, 139)"); // Prepare canvas for drawing main graph $draw = new ImagickDraw(); $draw->setStrokeAntialias(true); $draw->setStrokeWidth(2); // Prepare values for drawing main graph define('PADDING', 10); // Draw bottom bg define('TOP_SPACER', 10); $draw = new ImagickDraw(); $draw->setFillColor($color['bg']); $draw->setStrokeColor($color['habr']); $draw->polyline(array(array('x' => 0, 'y' => 0), array('x' => self::WIDTH - 1, 'y' => 0), array('x' => self::WIDTH - 1, 'y' => self::HEIGHT - 1), array('x' => 0, 'y' => self::HEIGHT - 1), array('x' => 0, 'y' => 0))); $this->_canvas->drawImage($draw); $draw->destroy(); // Draw texts $draw = new ImagickDraw(); $draw->setTextAlignment(Imagick::ALIGN_CENTER); $draw->setTextAntialias(true); $draw->setFillColor($color['karma']); $draw->polyline(array(array('x' => 1, 'y' => 1), array('x' => self::WIDTH / 2, 'y' => 1), array('x' => self::WIDTH / 2, 'y' => self::HEIGHT - 2), array('x' => 1, 'y' => self::HEIGHT - 2), array('x' => 1, 'y' => 1))); $draw->setFillColor($color['bg']); $draw->setFontSize(11); $draw->setFont(realpath('stuff/consolab.ttf')); $draw->annotation(self::WIDTH / 4, 11, sprintf('%01.2f', $this->_karma)); $draw->setFillColor($color['force']); $draw->polyline(array(array('x' => self::WIDTH / 2 + 1, 'y' => 1), array('x' => self::WIDTH - 2, 'y' => 1), array('x' => self::WIDTH - 2, 'y' => self::HEIGHT - 2), array('x' => self::WIDTH / 2 + 1, 'y' => self::HEIGHT - 2), array('x' => self::WIDTH / 2 + 1, 'y' => 1))); $draw->setFillColor($color['bg']); $draw->annotation(self::WIDTH / 4 * 3, 11, sprintf('%01.2f', $this->_habraforce)); $this->_canvas->drawImage($draw); $draw->destroy(); return true; }
public function printText($canvas, $size, $angle, $x, $y, $color, $fontfile, $text, $opacity = 100) { $draw = new ImagickDraw(); $draw->setFillColor(self::rgb($color)); $draw->setFontSize($size * $this->fontSizeScale); $draw->setFont($fontfile); $draw->setFillOpacity($opacity / 100); $canvas->annotateImage($draw, $x, $y, $angle, $text); }
/** * @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; }
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; }
function composite_title($title, $target, $photo_width) { $draw = new ImagickDraw(); $draw->setFont('Helvetica.ttf'); $draw->setFontSize(72); $draw->setFillColor('black'); $target->annotateImage($draw, $photo_width + 11, 46, 0, $title); $draw->setFillColor('white'); $target->annotateImage($draw, $photo_width + 10, 45, 0, $title); }
function blueDiscAlpha($width, $height) { $imagick = new Imagick(); $imagick->newImage($width, $height, 'none'); $draw = new ImagickDraw(); $draw->setStrokeOpacity(0); $draw->setFillColor('blue'); $draw->circle(2 * $width / 3, 2 * $height / 3, $width - ($width / 3 - $width / 4), 2 * $height / 3); $imagick->drawImage($draw); return $imagick; }
public function getDraw() { $draw = new \ImagickDraw(); $strokeColor = new \ImagickPixel($this->strokeColor); $fillColor = new \ImagickPixel($this->fillColor); $draw->setStrokeOpacity(1); $draw->setStrokeColor($strokeColor); $draw->setFillColor($fillColor); $draw->setStrokeWidth(2); return $draw; }
public function colorize($color, $alpha = 1) { $draw = new ImagickDraw(); $draw->setFillColor($color); if (is_float($alpha)) { $draw->setFillAlpha($alpha); } $geometry = $this->getImageGeometry(); $width = $geometry['width']; $height = $geometry['height']; $draw->rectangle(0, 0, $width, $height); $this->drawImage($draw); }
function drawText(\Imagick $imagick, $shadow = false) { $draw = new \ImagickDraw(); if ($shadow == true) { $draw->setStrokeColor('black'); $draw->setStrokeWidth(8); $draw->setFillColor('black'); } else { $draw->setStrokeColor('none'); $draw->setStrokeWidth(1); $draw->setFillColor('lightblue'); } $draw->setFontSize(96); $text = "Imagick\nExample"; $draw->setFont("../fonts/CANDY.TTF"); $draw->setGravity(\Imagick::GRAVITY_SOUTHWEST); $imagick->annotateimage($draw, 40, 40, 0, $text); if ($shadow == true) { $imagick->blurImage(10, 5); } return $imagick; }
/** * Draws one pixel to a given image * * @param Intervention\Image\Image $image * @return boolean */ public function execute($image) { $color = $this->argument(0)->required()->value(); $color = new Color($color); $x = $this->argument(1)->type('integer')->required()->value(); $y = $this->argument(2)->type('integer')->required()->value(); // prepare pixel $draw = new \ImagickDraw(); $draw->setFillColor($color->getPixel()); $draw->point($x, $y); // apply pixel return $image->getCore()->drawImage($draw); }
public function getImagineImage(ImagineInterface $imagine, FontCollection $fontCollection, $width, $height) { $fontPath = $fontCollection->getFontById($this->font)->getPath(); if ($this->getAbsoluteSize() !== null) { $fontSize = $this->getAbsoluteSize(); } elseif ($this->getRelativeSize() !== null) { $fontSize = (int) $this->getRelativeSize() / 100 * $height; } else { throw new \LogicException('Either relative or absolute watermark size must be set!'); } if (true || !class_exists('ImagickDraw')) { // Fall back to ugly image. $palette = new \Imagine\Image\Palette\RGB(); $font = $imagine->font($fontPath, $fontSize, $palette->color('#000')); $box = $font->box($this->getText()); $watermarkImage = $imagine->create($box, $palette->color('#FFF')); $watermarkImage->draw()->text($this->text, $font, new \Imagine\Image\Point(0, 0)); } else { // CURRENTLY DISABLED. // Use nicer Imagick implementation. // Untested! // @todo Test and implement it! $draw = new \ImagickDraw(); $draw->setFont($fontPath); $draw->setFontSize($fontSize); $draw->setStrokeAntialias(true); //try with and without $draw->setTextAntialias(true); //try with and without $draw->setFillColor('#fff'); $textOnly = new \Imagick(); $textOnly->newImage(1400, 400, "transparent"); //transparent canvas $textOnly->annotateImage($draw, 0, 0, 0, $this->text); //Create stroke $draw->setFillColor('#000'); //same as stroke color $draw->setStrokeColor('#000'); $draw->setStrokeWidth(8); $strokeImage = new \Imagick(); $strokeImage->newImage(1400, 400, "transparent"); $strokeImage->annotateImage($draw, 0, 0, 0, $this->text); //Composite text over stroke $strokeImage->compositeImage($textOnly, \Imagick::COMPOSITE_OVER, 0, 0, \Imagick::CHANNEL_ALPHA); $strokeImage->trimImage(0); //cut transparent border $watermarkImage = $imagine->load($strokeImage->getImageBlob()); //$strokeImage->resizeImage(300,0, \Imagick::FILTER_CATROM, 0.9, false); //resize to final size } return $watermarkImage; }
/** * Add border * @param integer $width Border width * @param string $color Border color * @return Imagick */ public function border($width, $color) { $border = new \ImagickDraw(); $border->setFillColor('none'); $border->setStrokeColor(new \ImagickPixel($color)); $border->setStrokeWidth($width); $widthPart = $width / 2; $border->line(0, 0 + $widthPart, $this->width, 0 + $widthPart); $border->line(0, $this->height - $widthPart, $this->width, $this->height - $widthPart); $border->line(0 + $widthPart, 0, 0 + $widthPart, $this->height); $border->line($this->width - $widthPart, 0, $this->width - $widthPart, $this->height); $this->image->drawImage($border); return $this; }
function renderImage() { //Create a ImagickDraw object to draw into. $draw = new \ImagickDraw(); $darkColor = new \ImagickPixel('brown'); //http://www.imagemagick.org/Usage/compose/#compose_terms $draw->setStrokeColor($darkColor); $draw->setFillColor('white'); $draw->setStrokeWidth(2); $draw->setFontSize(72); $draw->setStrokeOpacity(1); $draw->setStrokeColor($darkColor); $draw->setStrokeWidth(2); $draw->setFont("../fonts/CANDY.TTF"); $draw->setFontSize(140); $draw->setFillColor('none'); $draw->rectangle(0, 0, 1000, 300); $draw->setFillColor('white'); $draw->annotation(50, 180, "Lorem Ipsum!"); $imagick = new \Imagick(realpath("images/TestImage.jpg")); // $compositeModes = [ // // \Imagick::COMPOSITE_NO, \Imagick::COMPOSITE_ADD, \Imagick::COMPOSITE_ATOP, \Imagick::COMPOSITE_BLEND, \Imagick::COMPOSITE_BUMPMAP, \Imagick::COMPOSITE_CLEAR, \Imagick::COMPOSITE_COLORBURN, \Imagick::COMPOSITE_COLORDODGE, \Imagick::COMPOSITE_COLORIZE, \Imagick::COMPOSITE_COPYBLACK, \Imagick::COMPOSITE_COPYBLUE, \Imagick::COMPOSITE_COPY, \Imagick::COMPOSITE_COPYCYAN, \Imagick::COMPOSITE_COPYGREEN, \Imagick::COMPOSITE_COPYMAGENTA, \Imagick::COMPOSITE_COPYOPACITY, \Imagick::COMPOSITE_COPYRED, \Imagick::COMPOSITE_COPYYELLOW, \Imagick::COMPOSITE_DARKEN, \Imagick::COMPOSITE_DSTATOP, \Imagick::COMPOSITE_DST, \Imagick::COMPOSITE_DSTIN, \Imagick::COMPOSITE_DSTOUT, \Imagick::COMPOSITE_DSTOVER, \Imagick::COMPOSITE_DIFFERENCE, \Imagick::COMPOSITE_DISPLACE, \Imagick::COMPOSITE_DISSOLVE, \Imagick::COMPOSITE_EXCLUSION, \Imagick::COMPOSITE_HARDLIGHT, \Imagick::COMPOSITE_HUE, \Imagick::COMPOSITE_IN, \Imagick::COMPOSITE_LIGHTEN, \Imagick::COMPOSITE_LUMINIZE, \Imagick::COMPOSITE_MINUS, \Imagick::COMPOSITE_MODULATE, \Imagick::COMPOSITE_MULTIPLY, \Imagick::COMPOSITE_OUT, \Imagick::COMPOSITE_OVER, \Imagick::COMPOSITE_OVERLAY, \Imagick::COMPOSITE_PLUS, \Imagick::COMPOSITE_REPLACE, \Imagick::COMPOSITE_SATURATE, \Imagick::COMPOSITE_SCREEN, \Imagick::COMPOSITE_SOFTLIGHT, \Imagick::COMPOSITE_SRCATOP, \Imagick::COMPOSITE_SRC, \Imagick::COMPOSITE_SRCIN, \Imagick::COMPOSITE_SRCOUT, \Imagick::COMPOSITE_SRCOVER, \Imagick::COMPOSITE_SUBTRACT, \Imagick::COMPOSITE_THRESHOLD, \Imagick::COMPOSITE_XOR, // // ]; $draw->composite(\Imagick::COMPOSITE_MULTIPLY, -500, -200, 2000, 600, $imagick); //Create an image object which the draw commands can be rendered into $imagick = new \Imagick(); $imagick->newImage(1000, 300, "SteelBlue2"); $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(); }
protected function getImage() { $image = new \Imagick(); $image->newImage(2, 2, new \ImagickPixel('white')); $draw = new \ImagickDraw(); $draw->setFillColor(new \ImagickPixel('black')); $draw->color(0, 1, \Imagick::PAINT_POINT); $draw2 = new \ImagickDraw(); $draw2->setFillColor(new \ImagickPixel('black')); $draw2->color(1, 1, \Imagick::PAINT_POINT); $image->drawImage($draw); $image->drawimage($draw2); $image->setformat('png'); return $image; }
/** * @param ImageInterface $image * @return ImageInterface */ public function draw($image) { $strokeColor = new \ImagickPixel($this->getBorderColor()->getHexString()); $fillColor = new \ImagickPixel($this->getFillColor()->getHexString()); $draw = new \ImagickDraw(); $draw->setStrokeColor($strokeColor); $draw->setFillColor($fillColor); $draw->setStrokeWidth($this->borderSize); list($x, $y) = $this->pos; $left = $x + $this->width / 2; $top = $y + $this->height / 2; $draw->ellipse($left, $top, $this->width / 2, $this->height / 2, 0, 360); $image->getCore()->drawImage($draw); return $image; }
function test_shape(&$canvas) { $draw = new ImagickDraw(); $draw->setFillColor('transparent'); $draw->setStrokeColor('#F02B88'); $draw->setStrokeWidth(9); $draw->translate(200, 100); $draw->rectangle(-50, -50, 50, 50); $draw->translate(200, 100); $draw->ellipse(0, 0, 100, 80, 0, 360); $draw->skewX(-30); $draw->translate(200, 100); $draw->circle(0, 0, 50, 50); $canvas->drawImage($draw); }
/** * Draw rectangle to given image at certain position * * @param Image $image * @param integer $x * @param integer $y * @return boolean */ public function applyToImage(Image $image, $x = 0, $y = 0) { $rectangle = new \ImagickDraw(); // set background $bgcolor = new Color($this->background); $rectangle->setFillColor($bgcolor->getPixel()); // set border if ($this->hasBorder()) { $border_color = new Color($this->border_color); $rectangle->setStrokeWidth($this->border_width); $rectangle->setStrokeColor($border_color->getPixel()); } $rectangle->rectangle($this->x1, $this->y1, $this->x2, $this->y2); $image->getCore()->drawImage($rectangle); return true; }
/** * 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; }