Jump to content

[SOLVED] Text to Image??


TFD3

Recommended Posts

I have a URL that displays a background image and text overlay but I was wanting to know if its possible to combine the two and have it show as a image?

 

Here is the image/text overlay site:

http://beta.alabamaweather.org/radar/radarimages/fun2.php

 

Thanks,

Kenny

 

If you have GDlib installed, you can use:

 

http://ca3.php.net/manual/en/function.imagettftext.php

 

:)

Link to comment
Share on other sites

I have a URL that displays a background image and text overlay but I was wanting to know if its possible to combine the two and have it show as a image?

 

Here is the image/text overlay site:

http://beta.alabamaweather.org/radar/radarimages/fun2.php

 

Thanks,

Kenny

 

If you have GDlib installed, you can use:

 

http://ca3.php.net/manual/en/function.imagettftext.php

 

:)

Its installed but dont know how to use it really.

Link to comment
Share on other sites

That's why I linked to the manual. But I'll be nice this time:

 

<?php
    header("Content-Type: image/png");
    $im = imagecreatefrompng("background.png");
    $white = imagecolorallocate($im, 255, 255, 255);
    imagettftext($im, 12, 0, 10, 15, $white, "times.ttf", date());
    imagepng($im);
?>

 

Upload your font ("times.ttf") into the same directory as the script and "background.png".

 

 

Link to comment
Share on other sites

That's why I linked to the manual. But I'll be nice this time:

 

<?php
    header("Content-Type: image/png");
    $im = imagecreatefrompng("background.png");
    $white = imagecolorallocate($im, 255, 255, 255);
    imagettftext($im, 12, 0, 10, 15, $white, "times.ttf", date());
    imagepng($im);
?>

 

Upload your font ("times.ttf") into the same directory as the script and "background.png".

 

 

 

this is what I get...

http://beta.alabamaweather.org/radar/radarimages/fun3.php

 

Link to comment
Share on other sites

I see this in the headers:

 

Content-Type: text/html

 

Should be "image/png" ;) I edited the code I posted earlier, try it again.

 

works...cept the text. Here is what I have:

 

<?php
    header("Content-Type: image/png");
    $txt = testing;
    $im = imagecreatefrompng("http://beta.alabamaweather.org/radar/radarimages/background.png");
    $white = imagecolorallocate($im, 255, 255, 255);
    imagettftext($im, 12, 0, 10, 15, $white, "arial.ttf", date('$txt'));
    imagepng($im);
?>

 

and it displays: fun3.php when it should say testing

Link to comment
Share on other sites

<?php
    header("Content-Type: image/png");
    $txt = "testing";
    $im = imagecreatefrompng("http://beta.alabamaweather.org/radar/radarimages/background.png");
    $white = imagecolorallocate($im, 255, 255, 255);
    imagettftext($im, 12, 0, 10, 15, $white, "arial.ttf", $txt);
    imagepng($im);
?>

 

I don't know why you chose to make "testing" a constant or why you put $txt in date(), but try the code above.

Link to comment
Share on other sites

<?php
    header("Content-Type: image/png");
    $txt = "testing";
    $im = imagecreatefrompng("http://beta.alabamaweather.org/radar/radarimages/background.png");
    $white = imagecolorallocate($im, 255, 255, 255);
    imagettftext($im, 12, 0, 10, 15, $white, "arial.ttf", $txt);
    imagepng($im);
?>

 

I don't know why you chose to make "testing" a constant or why you put $txt in date(), but try the code above.

have no idea...but it now works...thank you!!!!!!!!!!!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.