DJ Mike's Tutorials: PHP

ImageMagick Functions

^

Imagick::writeImage

Description:
bool Imagick::writeImage ([ string $filename ] )

Writes an image 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.
Return Values
Returns TRUE on success.

Example


Text
<?
# text of annotation
$text "DJ Mike";
# path to font
$font "../../fonts/lokicola.ttf";
$fontsize 100;
$fontcolor "#ffff88";
# output file name 
$file "banner.gif";

# 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); # center text
$draw->setfont("$font"); # set font
$draw->setfontsize($fontsize); # set font size
$draw->setfillcolor("$fontcolor"); # set font color
$pallete->annotateImage $draw,,$offset0$text ); # annotate image, offset moves text down

# write file
$pallete->writeimage"$file");
# redirect browser to image
header("Location:banner.gif");
?>


^


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>