drawing news from my site onto a png

Need help with Photoshop, the GIMP, Illustrator, or others? Want to show off your work? Looking for advice on your newest Flash stuff?

Moderator: General Moderators

Mini-Me
Forum Commoner
Posts: 38
Joined: Sun Sep 12, 2004 4:07 pm

drawing news from my site onto a png

Post by Mini-Me »

Alright, I've got the image part working (YAY!).

http://www.minime001.net/test2.php

Code: Select all

<?php
  $img = imagecreatefrompng("test.PNG");
  $white = imagecolorallocate($img, 255,255,255);
  $text = "testing2";
  imagefttext($img, 8, 0, 2, 25, $white, 'fonts/tahoma.ttf', $text, array());
  header('Content-type: image/png');
  imagepng($img);
  imagedestroy($img);
?>
But what I need now is how I could make up a simple (secure) form that would write news to both my index page and this file. I realize how I could initialize the variables and everything, but what I need to know is where they would be submitted to and how they would be read. Could I write them to an xml file? that sounds like the easiest thing to do (if that's possible).
Breckenridge
Forum Commoner
Posts: 62
Joined: Thu Sep 09, 2004 11:10 pm
Location: Breckenridge, Colorado

Post by Breckenridge »

Are you using a database to store your data?
Mini-Me
Forum Commoner
Posts: 38
Joined: Sun Sep 12, 2004 4:07 pm

Post by Mini-Me »

well, no, but I can if I need to.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

We'll, it would be the easiest way..
Mini-Me
Forum Commoner
Posts: 38
Joined: Sun Sep 12, 2004 4:07 pm

Post by Mini-Me »

Ok, yeah, but then how would I do that?

Btw, I got the news to show up on both via a text file:
Image
http://www.minime001.net/news.txt

Code: Select all

<?PHP
$img = imagecreatefrompng("news.PNG");
$newstext = file('news.txt');
$white = imagecolorallocate($img, 255,255,255);
$howfar = 25;

foreach ($newstext as  $line)
{
  $line = trim($line);
  if (substr($line, 0, 4) == "<h3>" )
  {
    // Found Date
    $line = strip_tags($line);
    $currentdate = $line;
  }
  else
  {
    $line = strip_tags($line);
    if (strlen($line) > 3)
    {
      //Found Info
      imagefttext($img, 8, 0, 2, $howfar, $white, 'fonts/tahoma.ttf', $currentdate . ' ' . $line, array());
      $howfar += 15;
    }
  }
}
header('Content-type: image/png');
imagepng($img);
imagedestroy($img);
?>
But it's blurry. And runs off the screen. I don't see that I could do anything about it running off the screen except by shortening the news, but could I somehow convert to a numerical date instead of the month spelled out for that (MM/DD/YY)? If not, I guess I'd have to use separate txt files for both my page and the pic. And in that case, I definitly want a submit thing that would write to both of them. So how would I do all this?
Oh, and the blurry part. Can I make it just write a font like normal text (no blur, only white pixels) or something?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you're the one controlling the date information. you can change the format. Here's a hint, use a database.
Last edited by feyd on Fri Sep 24, 2004 12:46 pm, edited 1 time in total.
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

feyd wrote:you're the one controlling the date information. you can change the format. Here's a hint, use a database.
.... in which you store the unixtime of the post. When you fetch the data, do a

Code: Select all

<?php
$time = date ("d m, Y", $result['time']);
?>
to format the time...
Mini-Me
Forum Commoner
Posts: 38
Joined: Sun Sep 12, 2004 4:07 pm

Post by Mini-Me »

Here's a hint, use a database.
I could be wrong, but I'm pretty sure you're not the first one to tell me that. I'm also pretty sure you didn't read this part of my last post:
Ok, yeah, but then how would I do that?
I know how to set up a database, but that's as far as my knowledge goes. So, let me restate all my problems so everyone's on the same page:

• Can I make the text not blurry?
• What do I do with a database? (Completely clueless here. I understand I need one, but nothing else.)
• How can I have a form that will submit the data (How do I write it and what do I write it to?)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I'm not here to give full answers. I'm here to guide people, and get them to think on their own.
Can I make the text not blurry?
how is the posted image, blurry? I don't see anything blurry. I see some aliasing on the italised text, it looks perfectly fine otherwise.
What do I do with a database? (Completely clueless here. I understand I need one, but nothing else.)
you store the information you want in this image(s) in seperate fields for the date, and any other categoric type information.
How can I have a form that will submit the data (How do I write it and what do I write it to?)
You create a form processor that validates and stores the information into the database for your image function to retrieve. Alternately, if this is the only place the image gets update information from, you can have this script do the actual creation of the image, so that the server creates once, but uses many times. caching so to speak.
Mini-Me
Forum Commoner
Posts: 38
Joined: Sun Sep 12, 2004 4:07 pm

Post by Mini-Me »

I don't expect you to give me a long post of code or anything. I just don't understand a lot of this, and therefore need help with it so I can figure out what to do. ;)

aliasing, yeah. that's what I meant. But you think it looks ok that way? okay, I guess.

when you say I can store the information in fields, .. well... so what's a field? ^^;

"form processor...." yeah, I knew I had to do something like that, I just don't know how to do any of it. How would I validate it? (And when you say validate, you do mean to make sure I'm the only one submitting, etc, right?) How would I have a script create an image that isn't recreated when it's viewed? You mean like I could make a completely separate png that, after created, would function completely separate from the script?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

aliasing, yeah. that's what I meant. But you think it looks ok that way? okay, I guess.
if the font rendering function supports anti-aliasing, I'd use it. However, the font itself may not support it all that well. If you're feeling a bit eager to learn some graphics stuff, you can search the net for an edge based anti-aliasing routine and attempt to convert it to php. Unless there's a function in the image's I'm not especially aware of. You can have the image functions resample the image, by making it 2 or more times larger, then resample it, which should partly anti-alias it down a bit.
when you say I can store the information in fields, .. well... so what's a field? ^^;
fields = columns. Seperated types, for example, a datetime or int for the date, a varchar for the text to actually drop
"form processor...." yeah, I knew I had to do something like that, I just don't know how to do any of it. How would I validate it?
we've had the pleasure of talking about form validation about 20,000 times. [devnet]+form +valid*[/devnet]
And when you say validate, you do mean to make sure I'm the only one submitting, etc, right?
That's a piece of it. The validation is more to verify that the data being submitted is correct for your set up.
How would I have a script create an image that isn't recreated when it's viewed? You mean like I could make a completely separate png that, after created, would function completely separate from the script?
you save the image to the server's file system, so you can just link to it normally. You may need to have the proper cache settings though. But it does save your server from having to render it for every page query. ... something to think about.
Mini-Me
Forum Commoner
Posts: 38
Joined: Sun Sep 12, 2004 4:07 pm

Post by Mini-Me »

alright. I'm starting to see how this'll all come together.

But before I can do anything, I need to get started. I can create a database and a user for it via my control panel for my site (which I usually don't like using). But what do I do after that? I can now (sorta) see how to submit a password to a database, but how would I read it? what would go inside the database? um... what exactly is a database? ^^; I've tried to google a tut about databases, but haven't found anything so far. You know of one I could read?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

to access your database you can use phpmyadmin
Mini-Me
Forum Commoner
Posts: 38
Joined: Sun Sep 12, 2004 4:07 pm

Post by Mini-Me »

aha, found a place where it says fields. For that, I put in 2, right? So what do I do then (where's a newb faq!? T_T )?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

http://www.oreilly.com/catalog/javadtab ... r/ch02.pdf may help you out a bit.
there have been many many many threads regarding how to set up tables and database design..
Post Reply