Convert a string into an image?

Reply

Join Date: Feb 2008
Posts: 14
Reputation: neclark2 is an unknown quantity at this point 
Solved Threads: 0
neclark2 neclark2 is offline Offline
Newbie Poster

Convert a string into an image?

 
0
  #1
Sep 22nd, 2008
Does anyone know if there's a function in php that will allow me to convert a string into an image?
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 585
Reputation: Will Gresham is on a distinguished road 
Solved Threads: 98
Sponsor
Will Gresham's Avatar
Will Gresham Will Gresham is offline Offline
Posting Pro

Re: Convert a string into an image?

 
0
  #2
Sep 22nd, 2008
The GD Library will alow you to add text to an image, the GD library can be obtained from http://www.libgd.org/Main_Page
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 1
Reputation: amir_php is an unknown quantity at this point 
Solved Threads: 0
amir_php amir_php is offline Offline
Newbie Poster

Re: Convert a string into an image?

 
0
  #3
Sep 22nd, 2008
Originally Posted by neclark2 View Post
Does anyone know if there's a function in php that will allow me to convert a string into an image?
Draw a string horizontally (PHP 4, PHP 5)

bool imagestring ( resource image, int font, int x, int y, string string, int color )

<?php
// create a 100*30 image
$im = imagecreate(100, 30);

// white background and blue text
$bg = imagecolorallocate($im, 255, 255, 255);
$textcolor = imagecolorallocate($im, 0, 0, 255);

// write the string at the top left
imagestring($im, 5, 0, 0, "Hello world!", $textcolor);

// output the image
header("Content-type: image/png");
imagepng($im);
?>
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,076
Reputation: Shanti Chepuru is on a distinguished road 
Solved Threads: 98
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Veteran Poster

Re: Convert a string into an image?

 
0
  #4
Sep 23rd, 2008
once refer these links:
http://www.rafaeldohms.com.br/2008/0...e-with-php/en/
http://www.developertutorials.com/tu...620/page1.html

or try this:
  1. <?php
  2. $image = ImageCreateFromPNG("base.png");
  3. $color = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
  4. $colorShadow = imagecolorallocate($image, 0x66, 0x66, 0x66);
  5. $font = 'arial.ttf';
  6. $fontSize = "10";
  7. $fontRotation = "0";
  8. $str = "Example of GD in PHP. Date: " . date("m-j-Y g:i:s (a)");
  9.  
  10. /* Shadow */
  11. ImageTTFText($image, $fontSize, $fontRotation, 7, 22, $colorShadow, $font, $str);
  12.  
  13. /* Top Level */
  14. ImageTTFText($image, $fontSize, $fontRotation, 5, 20, $color, $font, $str);
  15.  
  16. header("Content-Type: image/PNG");
  17. ImagePng ($image);
  18. imagedestroy($image);
  19. ?>
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 3366 | Replies: 3
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC