very small correction required for this code.. can you fix??
Posted: 2011-12-22T06:45:59-07:00
Hello Webmasters,
this is the IMagick code to create moving text image ...
it is not creating "ani.gif" but it is creating list of images from "ani-0.gif" to "ani-9.gif" ....yes looks very simple... but still not working??? can any one fix this??? waiting for your response asap..
this is the IMagick code to create moving text image ...
Code: Select all
<?
/*** a new Imagick object ***/
$aniGif = new Imagick();
/*** set the image format to gif ***/
$aniGif->setFormat( "gif" );
/*** a new ImagickPixel object for the colors ***/
$color = new ImagickPixel( "white" );
/*** set color to white ***/
$color->setColor( "white" );
/*** the text for the image ***/
$string = "write what ever";
/*** a new draw object ***/
$draw = new ImagickDraw();
/*** set the draw font to helvetica ***/
$draw->setFont( "arial.ttf" );
/*** loop over the text ***/
for ( $i = 0; $i <= strlen( $string ); $i++ )
{
/*** grab a character ***/
$part = substr( $string, 0, $i );
/*** create a new gif frame ***/
$aniGif->newImage( 100, 50, $color );
/*** add the character to the image ***/
$aniGif->annotateImage( $draw, 10, 10, 0, $part );
/*** set the frame delay to 30 ***/
$aniGif->setImageDelay( 30 );
}
/*** write the file ***/
$aniGif->writeImages('ani.gif', $out);
?>