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
https://forums.phpfreaks.com/topic/60021-solved-text-to-image/#findComment-298506
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
https://forums.phpfreaks.com/topic/60021-solved-text-to-image/#findComment-298512
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
https://forums.phpfreaks.com/topic/60021-solved-text-to-image/#findComment-298514
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
https://forums.phpfreaks.com/topic/60021-solved-text-to-image/#findComment-298516
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
https://forums.phpfreaks.com/topic/60021-solved-text-to-image/#findComment-298522
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
https://forums.phpfreaks.com/topic/60021-solved-text-to-image/#findComment-298525
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
https://forums.phpfreaks.com/topic/60021-solved-text-to-image/#findComment-298530
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.