Code: Select all
<?php
// Text effect 2 - patterned text
$magick_wand = NewMagickWand();
$d_wand = NewDrawingWand();
$p_wand = NewPixelWand();
$pattern_file = "11.jpg";
$pattern_name = "#ice";
$t_wand=NewMagickWand();
MagickReadImage($t_wand,$pattern_file);
// Read the tile's width and height
$w = MagickGetImageWidth($t_wand);
$h = MagickGetImageHeight($t_wand);
DrawPushPattern($d_wand, $pattern_name, 0, 0, $w, $h);
if( DrawComposite($d_wand, MW_SrcOverCompositeOp, 0, 0, $w, $h, $t_wand)){
echo "DrawComposite ok<br>";
}
if( DrawPopPattern($d_wand)){
echo "DrawPopPattern ok<br>";
}
if( DrawSetFillPatternURL($d_wand, $pattern_name) ){
echo "ok";
}else{
print_R(DrawGetException($d_wand));
echo DrawGetExceptionString($d_wand);
echo "failse";
}
PixelSetColor($p_wand,"#ffffff");
// Create a new transparent image
MagickNewImage($magick_wand,640,480,$p_wand);
// Set up a 72 point font
// DrawSetFont ($d_wand, "Verdana-Bold-Italic" ) ;
DrawSetFontSize($d_wand,100);
// Now draw the text
DrawAnnotation($d_wand,140,140,"Magick");
// Draw the image on to the magick_wand
MagickDrawImage($magick_wand,$d_wand);
// Trim the image
//MagickTrimImage($magick_wand,0);
// Add a white border
//PixelSetColor($p_wand,"white");
// MagickBorderImage($magick_wand,$p_wand,5,5);
MagickSetImageFormat($magick_wand,"png");
// and write it
MagickWriteImage($magick_wand,"text_pattern.png");
/* Clean up */
DestroyMagickWand($magick_wand);
DestroyDrawingWand($d_wand);
DestroyPixelWand($p_wand);
?>