Uploading basic resources

  • Optionally (if you wish to use non built-in GD fonts) choose your favorite GD Fonts from above mentioned resources and Upload the GDF files to your webroot/sig/gd_fonts folder.

  • Create background images for your dynamic signatures and upload them to your webroot/sig/images folder. For instance, we'll use this one throughout our examples:

  • Create a file called dynamic_gd_image.php and upload it to the webroot/sig/includes folder, with the following contents:

    <?php
    $gdfonts 
    = array(
        
    '8x13iso''9x15iso''andale12''atommicclock''bmreceipt',
        
    'chowfun''courier8''dimurph''georgia8''proggyclean',
        
    'proggysquare''systemex''terminal6''trisk'
    );

    //
    //
    //
    if( !isset($image_info) || !isset($image_text) )
    {
        exit;
    }

    //
    //
    //
    $sz = @getimagesize('./images/'.$image_info['image']);
    if( !
    $sz )
    {
        exit;
    }
    $image_w $sz[0];
    $image_h $sz[1];

    //
    //
    //
    @header('Content-type: image/png');

    $im = @imagecreatefromgif('./images/'.$image_info['image']);
    $rgb = ( isset($image_info['color']) ? $image_info['color'] : array(255255255) );
    $bgColor imagecolorallocate($im$rgb[0], $rgb[1], $rgb[2]);

    for( 
    $i 0$i count($image_text); $i++ )
    {
        if( !
    is_numeric($image_text[$i]['font']) )
        {
            
    $font 1;
        }
        else if( 
    $image_text[$i]['font'] < )
        {
            
    $font $image_text[$i]['font'] * -1;
        }
        else
        {
            if( !(
    $font = @imageloadfont('./gd_fonts/'.$gdfonts[$image_text[$i]['font']].'.gdf')) )
            {
                
    $font 1;
            }
        }
        
    $rgb $image_text[$i]['color'];
        
    $fgColor imagecolorallocate($im$rgb[0], $rgb[1], $rgb[2]);
        
    imagestring($im$font$image_text[$i]['x'], $image_text[$i]['y'], $image_text[$i]['text'], $fgColor);
    }

    imagepng($im);
    imagedestroy($im);
    ?>

    For now, just setup the $gdfonts array with the names of the GD fonts you uploaded.

    As per comments on the code... I'll leave this "small detail" to your own eye. Well, I already posted links to the PHP manual for all the relevant GD functions used here. This is a good oportunity to experiment for yourself. ;)