I've been attempting to work with the following code to generate a background image with text on it that includes a user's name, email address, and other pertinant information. However, I can't figure out how to get the code to allow multiple lines of text. The code I'm using is here :

header("Content-type: image/png");
$im = imagecreatefrompng("images/1.png");
$font_a = 4;
$xpos_a = 5;
$ypos_a = 25;
$string_a = "$username $email $data1 $data2";
$white = imagecolorallocate($im, 255, 255, 255);
imagestring($im, $font_a, $xpos_a, $ypos_a, $string_a, $white);
imagepng($im);

I've tried to create multiple font, x and y pos, and string variables but that create an error. I've also tried to put standard HTML tags like <BR> between each variable in the string, which still only generates an image with the string on a single line with the <BR> tag between them. I've been hunting around for the last day or so looking for ways to do this with no luck... I can find hundreds of examples online about how to add text to an image, but nothing on how to add multiple lines of text to an image.

Any help would be really appreciated.

    Nevermind... after some more tweaking, I figured it out.

    For anyone who may need help on how to do this, I've included the code I'm using below. Simply adding another line "imagestring" with updated variables on the location of the image you want the text will do the trick.

    header("Content-type: image/png");
    $im = imagecreatefrompng("images/1.png");
    $font_a = 4;
    $xpos_a = 5;
    $ypos_a = 25;
    $string_a = "$username";
    $font_b = 2;
    $xpos_b = 5;
    $ypos_b = 42;
    $string_b = "$email";
    $font_c = 2;
    $xpos_c = 5;
    $ypos_c = 58;
    $string_c = "$data1";
    $font_d = 2;
    $xpos_d = 5;
    $ypos_d = 74;
    $string_d = "$data2";
    $white = imagecolorallocate($im, 255, 255, 255);
    imagestring($im, $font_a, $xpos_a, $ypos_a, $string_a, $white);
    imagestring($im, $font_b, $xpos_b, $ypos_b, $string_b, $white);
    imagestring($im, $font_c, $xpos_c, $ypos_c, $string_c, $white);
    imagestring($im, $font_d, $xpos_d, $ypos_d, $string_d, $white);
    imagepng($im);
    
      Write a Reply...