Jump to content

Dynamic Image reading from .txt


Vini

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]
Link to comment
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.
Link to comment
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.
Link to comment
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
Link to comment
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.