PHPRO.ORG

By Kevin Waterson

This simple example uses the imagick extension to create text on an image with halo or glow effect. The effect is quite simple to create by annotating in-focus text over blurred text. This can be used to create dynamic images with text for many uses.


<?php
    
/*** a new imagick object ***/
    
$im = new Imagick();

    
/*** create a new image ***/
    
$im->newImage500200'transparent' );

    
/*** a new draw object ***/
    
$draw = new ImagickDraw();

    
/*** set the font ***/
    
$draw->setFont('Helvetica');

    
/*** set the font size ***/
    
$draw->setFontSize52 );

    
/*** set the gravity ***/
    
$draw->setGravityImagick::GRAVITY_CENTER );

    
/*** set the fill color ***/
    
$draw->setFillColor"orange" );

    
/*** set the blurred text ***/
    
$im->annotateImage$draw000"PHPRO.ORG" );
    
$im->blurImage1010 );

    
/*** set the focused text ***/
    
$im->annotateImage$draw000"PHPRO.ORG" );

    
/*** set the image format to png ***/
    
$im->setImageFormat"png" );

    
/*** display the image ***/
    
header"Content-Type: image/png" );
    echo 
$im;
?>

Demonstration

halo.png