Username: Save?
Password:
Home Forum Links Search Login Register*
    News: Welcome to the TechnoWorldInc! Community!
Recent Updates
[May 13, 2025, 02:04:25 PM]

[May 13, 2025, 02:04:25 PM]

[May 13, 2025, 02:04:25 PM]

[May 13, 2025, 02:04:25 PM]

[April 12, 2025, 01:54:20 PM]

[April 12, 2025, 01:54:20 PM]

[April 12, 2025, 01:54:20 PM]

[April 12, 2025, 01:54:20 PM]

[March 12, 2025, 03:05:30 PM]

[March 12, 2025, 03:05:30 PM]

[March 12, 2025, 03:05:30 PM]

[March 12, 2025, 03:05:30 PM]

[January 03, 2025, 03:29:12 PM]
Subscriptions
Get Latest Tech Updates For Free!
Resources
   Travelikers
   Funistan
   PrettyGalz
   Techlap
   FreeThemes
   Videsta
   Glamistan
   BachatMela
   GlamGalz
   Techzug
   Vidsage
   Funzug
   WorldHostInc
   Funfani
   FilmyMama
   Uploaded.Tech
   Netens
   Funotic
   FreeJobsInc
   FilesPark
Participate in the fastest growing Technical Encyclopedia! This website is 100% Free. Please register or login using the login box above if you have already registered. You will need to be logged in to reply, make new topics and to access all the areas. Registration is free! Click Here To Register.
+ Techno World Inc - The Best Technical Encyclopedia Online! » Forum » THE TECHNO CLUB [ TECHNOWORLDINC.COM ] » Programming Zone » PHP
 PHP: Generate Dynamic Images from Text
Pages: [1]   Go Down
  Print  
Author Topic: PHP: Generate Dynamic Images from Text  (Read 1935 times)
Khushi
Global Moderator
Adv. Member
*****



Karma: 4
Offline Offline

Posts: 329

Hello!!


View Profile
PHP: Generate Dynamic Images from Text
« Posted: January 03, 2007, 12:23:20 AM »


How to create images from text dynamically (quote generator)

Here is a piece of code i have used in the past. It uses a text file on the server, named quote.txt, but you could link it to any sort of inuput.

I have read many tutorials which claim to do the same, but most do not work, this WILL work, a test out link is provided, and this is the exact code used.

Code:
<?php 
Header 
("Content-type: image/gif"); 

$textfile "quote.txt"
$quotes = array(); 
if(
file_exists($textfile)){ 
     
$quotes file($textfile); 
     
srand ((float) microtime() * 10000000); 
     
$string '-'.$quotes[array_rand($quotes)]; 
     
$string substr($string,0,strlen($string)-2); 

else{ 
     
$string "No 'Quote' available at this time."

$font  2
$width  ImageFontWidth($font)* strlen($string); 
$height ImageFontHeight($font); 
$im ImageCreate($width,$height); 

$x=imagesx($im)-$width 
$y=imagesy($im)-$height
$background_color imagecolorallocate ($im242242242); //white background 
$text_color imagecolorallocate ($im00,0);//black text 
$trans_color $background_color;//transparent colour 
imagecolortransparent($im$trans_color); 
imagestring ($im$font$x$y,  $string$text_color); 

imagegif($im); 
ImageDestroy($im); 
?>

Try it out at: www.marvingohan.com

Logged

« Reply #1 Posted: August 13, 2007, 01:39:10 PM »
Hellraiser
TWI Trailblazer
*******



Karma: 3
Offline Offline

Posts: 2476


View Profile
Re: PHP: Generate Dynamic Images from Text
« Reply #1 Posted: August 13, 2007, 01:39:10 PM »

hey..thanks for this recipe..Smiley
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Copyright © 2006-2023 TechnoWorldInc.com. All Rights Reserved. Privacy Policy | Disclaimer
Page created in 0.225 seconds with 25 queries.