Jump to content

Archived

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

Vini

Dynamic Image reading from .txt

Recommended Posts

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]

[code]<?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);

?>

[/code]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[!--quoteo(post=371533:date=May 5 2006, 09:09 AM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ May 5 2006, 09:09 AM) [snapback]371533[/snapback][/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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[code] <?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);
?>[/code]

is something i found which reads from the file, but

Share this post


Link to post
Share on other sites

×

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.