DJ Mike's Tutorials: PHP

ImageMagick Functions

^

ImagickDraw::pushPattern

Description:
bool ImagickDraw::pushPattern ( string $pattern_id , float $x , float $y , float $width , float $height )

Indicates that subsequent commands up to a PopPattern() command comprise the definition of a named pattern. The pattern space is assigned top left corner coordinates, a width and height, and becomes its own drawing space. Anything which can be drawn may be used in a pattern definition. Named patterns may be used as stroke or brush definitions.

Parameters:
pattern_id
the pattern Id to be used by setFillPatternURL
x
x coordinate of the top-left corner
y
y coordinate of the top-left corner
width
width of the pattern
height
height of the pattern
Return Values
Returns TRUE on success or FALSE on failure.

Example


Text
<?php
# path to font
$font "../../fonts/lokicola.ttf";
# text of annotation
$text "DJ Mike";
# bgcolor
$bg "#fad888";
# font size
$fontsize 100;
# path to fill image
$pattern = new Imagick'../../images/marb015.jpg' );
# offset to adjust image position
$offset 14;
#########################################

# create imagick object
$pallete = new Imagick();
# give it size and color attributes
$pallete->newimage(375,140"$bg");

# Create imagickdraw object
$draw = new ImagickDraw();
$draw->setfont("$font"); # set font

#### Start a new pattern called "marble" ####
$draw->pushPattern'marble'  0  0  360  270 );
# composite fill image over it
$draw->compositeImagick::COMPOSITE_OVER00375140$pattern  );
# end pattern definition
$draw->popPattern();
#############################################

# Set pattern called "marble" as the fill
$draw->setFillPatternURL'#marble' );
# set gravity
$draw->setgravity(imagick::GRAVITY_CENTER); 
# set font size
$draw->setFontSize$fontsize );
# annotate
$draw->annotation0$offset"$text);

# apply draw object to imagick object
$pallete->drawImage$draw );
# give it a raised border
$pallete->raiseImage1010140100TRUE);
# set format
$pallete->setImageFormat'png' );
# Output the image 
header"Content-Type: image/png" );
echo 
$pallete;
?>


^


Created by DJ Mike from Santa Barbara

DJ Mike


Dance Away Santa Barbara's Home Page
<a href="http://www.statcounter.com/" target="_blank"> <img src="http://c5.statcounter.com/counter.php?sc_project=1321035&java=0&security=da2193dc" alt="counter free hit invisible" border="0" /></a>