Jump to content

Recommended Posts

Hi i want to create text image using php. Its all are working fine. But when i am trying to multi line text its not working. If i am use '\n' and '<br>' image displayed as it is \n and <br>. Here is my scripts. Can i anyone guide me.

 

<?
header("Content-type: image/png"); // Tell  the browser it's an image, not a .php file.

$text = 'Sample text\nSample text';

$number = strlen($text);  // Count the chars in the text.

$number = ($number*7)+9; // Times this by 7 and add 9 to make it look the right size.

$im = imagecreate($number, 24); // Create the basic size, $number x 24

$colour1 = imagecolorallocate($im, 0, 0, 0); // Background (RGB) black.

$colour2 = imagecolorallocate($im, 255, 255, 255); // Background white.

imagestring($im, 3, 5, 5,  $text, $colour2); // Add the text to the image.

imagepng($im); // Create and display the image.

imagedestroy($im); // Cast the image from the server (will cause lag eventually if you don't).

?>

 

 

Thanq

Link to comment
https://forums.phpfreaks.com/topic/125104-create-text-image-using-php/
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.