function GifCATCHA($string,$delay,$finaldelay,$output=false) { /* This object will hold the animation */ $animation = new Imagick(); /* Set the format to gif. All created images will be gifs*/ $animation->setFormat( "gif" ); /* Create a pixel to handle colors */ $color = new ImagickPixel( "white" ); /* The first frame */ $color->setColor( "white" ); /* Create a new ImagickDraw object and set the font Text color defaults to black */ $draw = new ImagickDraw(); /* You can get configured fonts with $im->queryFonts or use /path/to/file.ttf */ $draw->setFont( "Helvetica" ); /* Loop trough the string.. */ for ( $i = 0; $i <= strlen( $string ); $i++ ) { /* Take some characters for this frame */ $part = substr( $string, 0, $i ); /* Create a new frame */ $animation->newImage( 100, 50, $color ); /* Annotate the characters on the image */ $animation->annotateImage( $draw, 10, 10, 0, $part ); /* Set a little higher delay for the frame*/ $animation->setImageDelay($delay); } /* The last frame contains the same text with bold */ $draw->setFont( "Helvetica" ); /* One more frame */ $animation->newImage( 100, 50, $color ); /* Annotate the bold text on the image */ $animation->annotateImage( $draw, 10, 10, 0, $string ); /* The bold can be visible a little longer time */ $animation->setImageDelay($finaldelay); if($output) { file_put_contents($output,$animation->getImagesBlob(),'w+'); } else { /* Display the output as an animation. Use getImagesBlob to get all images combined */ header( "Content-Type: image/gif" ); echo $animation->getImagesBlob(); } } ?>