Jump to content


Photo

Dynamic Image reading from .txt


  • Please log in to reply
4 replies to this topic

#1 Vini

Vini
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 05 May 2006 - 01:19 PM

I've currently got a dynamic image setup, but i want it to read & output lines from a text file. instead of accept the form input.

Im no coder so not sure where to begin, anyone shed any light?

Below is the code for my [a href=\"http://www.vini.co.uk/dyn/\" target=\"_blank\"]DynaPic[/a]

<?php

header("Content-type: image/png");
$string = $_POST['quote'];
$im    = imagecreatefrompng("idudesays.png");
$colour = imagecolorallocate($im, 100, 100, 100);
imagestring($im, 3, 90, 23, $string, $colour);
imagepng($im);
imagedestroy($im);

?>



#2 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 05 May 2006 - 02:09 PM

I'm not completely sure I understand the question or how it relates to your dynamic image script, but you should look into fopen(), fread(), fwrite() for reading and writing text files.

Info: PHP Manual


#3 Vini

Vini
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 05 May 2006 - 02:44 PM

[!--quoteo(post=371533:date=May 5 2006, 09:09 AM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ May 5 2006, 09:09 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
I'm not completely sure I understand the question or how it relates to your dynamic image script, but you should look into fopen(), fread(), fwrite() for reading and writing text files.
[/quote]

I have done, and they dont mean anything to me :S

Im after listing quotes line by line in a text file, which i will read randomly and display on the image.

#4 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 05 May 2006 - 02:48 PM

Well I'm not going to write it for you. The examples provided in the manual don't get much more clear on how to use them.

Info: PHP Manual


#5 Vini

Vini
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 05 May 2006 - 03:35 PM

<?php
header("Content-type: image/png");

//change this to the number of random quotes you want (for example if you had 15 quotes it would be $number = rand(1,15);
$number = rand(1,9);
//change your random quotes here
if($number==1)$string2 = "all your base r belong 2 us";
if($number==2)$string2 = "somebody set up us the bomb";
if($number==3)$string2 = "Resistance is futile";
if($number==4)$string2 = "R0D3NTS are cute";
if($number==5)$string2 = "H4X0R in thE yur PC1?!";
if($number==6)$string2 = "Dude w3re's my c4r?";
if($number==7)$string2 = "s0m3on3 st0l3 my mega hurtz!!";
if($number==8)$string2 = "move zig for great justice";
if($number==9)$string2 = "Rodents make the world cool";

//put your image name here (must be a png)
$im = imagecreatefrompng("idudesays.png");
//change your text color here ( must be the hex value) ex. 255,255,255 would be white
$color = imagecolorallocate($im, 100, 100, 100);

//change your X & y coordinates here to place the text on your image where you want it
//(these will center the text on a 400x100 image)
$px=90;
$py=12;
//no need to touch this unless you know what your doing
imagestring($im, 3, $px, $py, $string, $color);
imagestring($im, 3, $px, $py+12, $string2, $color);

imagepng($im);
imagedestroy($im);
?>

is something i found which reads from the file, but




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users