DJ Mike's Tutorials: PHP

ImageMagick Functions

^

Imagick::writeImages

Description:
bool Imagick::writeImages ( string $filename , bool $adjoin )

Writes an image or image sequence to the specified filename. If the filename parameter is NULL, the image is written to the filename set by Imagick::ReadImage() or Imagick::SetImageFilename().

Parameters:
filename
The file name of the image that is generated. The directory of the output image has to have permissions set so that PHP can write to it.
adjoin
If TRUE the output is a single image. If FALSE each frame is written as a separate image.
Return Values
Returns TRUE on success.

Example


Text
<?
$text 
"DJ Mike";
$font "../../fonts/lokicola.ttf";
$fontsize 100;
$fontcolor "#ffff88";
$file "ani_banner_1.gif";

$glow_radius 3;
# Three glow colors
$glow = array( "#ff0000""#ff8800""#ffff00" );
$delay 15;
# moves text down
$offset 14;

# make a black pallete
$pallete = new Imagick;
$pallete->newimage(375,140"#000000");
# set pallet format to gif
$pallete->setimageformat("gif");

# make a draw object with settings
$draw = new imagickdraw();
$draw->setgravity(imagick::GRAVITY_CENTER);
$draw->setfont("$font");
$draw->setfontsize($fontsize);

# clone pallete to make 3 blank frames
$frame_0 $pallete->clone();
$frame_1 $pallete->clone();
$frame_2 $pallete->clone();

# put them in an array
$frames = array($frame_0$frame_1$frame_2);

# loop through frames, double glow radius each time, annotate
foreach( $frames as $frame)
 {
  
# Loop through glow colors, annotate and blur
  
foreach( $glow as $color)
  {
   
$draw->setfillcolor("$color");
   
$frame->annotateImage $draw,,$offset0$text );
   
$frame->annotateImage $draw,,$offset0$text );
   
$frame->BlurImage$glow_radius$glow_radius );
   
$frame->setImageDelay("$delay");
  }
 
# top layer of text over glow
 
$draw->setfillcolor("$fontcolor");
 
# center annotate on top of offset annotates
 
$frame->annotateImage $draw,,$offset0$text );
 
# double glow radius for next loop
 
$glow_radius $glow_radius*2;
 }

# add frames
$frame_0->addImage($frame_1);
$frame_0->addImage($frame_2);

# write animation
$frame_0->writeimages"$file"TRUE);
# redirect browser to image
header("Location:$file");
?>


^


Was this webpage useful to you? You can support this website by donating.


Created by DJ Mike from Santa Barbara

DJ Mike


<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>