Sets the URL to use as a fill pattern for filling objects. Only local URLs ("#identifier") are supported at this time. These local URLs are normally created by defining a named fill pattern with PushPattern/PopPattern.
<?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->composite( Imagick::COMPOSITE_OVER, 0, 0, 375, 140, $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->annotation( 0, $offset, "$text" );
# apply draw object to imagick object
$pallete->drawImage( $draw );
# give it a raised border
$pallete->raiseImage( 10, 10, 140, 100, TRUE);
# set format
$pallete->setImageFormat( 'png' );
# Output the image
header( "Content-Type: image/png" );
echo $pallete;
?>
|
|
|