Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-09-2009, 09:59 AM   PM User | #1
Blatch
New Coder

 
Join Date: Mar 2003
Location: USA
Posts: 99
Thanks: 24
Thanked 0 Times in 0 Posts
Blatch is an unknown quantity at this point
dynamic image with stats?

So I'm trying to familiarize myself with gd. I know how to add text to an image with it, but I want something more.

http://pbcodes.com/imgview/3/

If you look there, this is what I'm going for. Auto-updating stats on the .png image.

I can do this just fine (get stats and show image) but my image is viewed through the php file I create. How can I get it to update MY png image to show the latest stats from the php file?
Blatch is offline   Reply With Quote
Old 09-09-2009, 12:35 PM   PM User | #2
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,045
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
Give us a PNG image all by itself (blank),
and then the same PNG image with text on it (example of how you want it to look).

We can then show you how to put "any text" onto your blank PNG image
so it looks like your example (with text on it).
mlseim is offline   Reply With Quote
Old 09-09-2009, 03:22 PM   PM User | #3
bacterozoid
Regular Coder

 
bacterozoid's Avatar
 
Join Date: Jun 2002
Location: USA
Posts: 486
Thanks: 23
Thanked 35 Times in 35 Posts
bacterozoid is an unknown quantity at this point
If you can view your image through your PHP file, like you say, then just use <img src="whatever.php"/> and it will work just fine.
bacterozoid is offline   Reply With Quote
Old 09-09-2009, 07:43 PM   PM User | #4
Blatch
New Coder

 
Join Date: Mar 2003
Location: USA
Posts: 99
Thanks: 24
Thanked 0 Times in 0 Posts
Blatch is an unknown quantity at this point
I know how to put text on it, I was just wondering how I can get that so the image is imagename.png (with the dynamic text) and not imagename.php?
Blatch is offline   Reply With Quote
Old 09-09-2009, 08:20 PM   PM User | #5
bacterozoid
Regular Coder

 
bacterozoid's Avatar
 
Join Date: Jun 2002
Location: USA
Posts: 486
Thanks: 23
Thanked 35 Times in 35 Posts
bacterozoid is an unknown quantity at this point
Well, you can either configure your server to execute image files as PHP, then save your php file with the extension of your choice (who knows what side-effects that would have), or have your PHP script save the image on your server every time it runs...

But all that's really a lot of extra work. Why can't you just use the PHP extension?
bacterozoid is offline   Reply With Quote
Old 09-09-2009, 09:31 PM   PM User | #6
Blockis
New Coder

 
Join Date: Sep 2009
Posts: 36
Thanks: 4
Thanked 0 Times in 0 Posts
Blockis is an unknown quantity at this point
Most forums don't allow images as PHP. Besides, most sites now-a-days like Runescape, Xbox Live, etc use a .PNG for stats.

Blockis
Blockis is offline   Reply With Quote
Old 09-09-2009, 09:35 PM   PM User | #7
bacterozoid
Regular Coder

 
bacterozoid's Avatar
 
Join Date: Jun 2002
Location: USA
Posts: 486
Thanks: 23
Thanked 35 Times in 35 Posts
bacterozoid is an unknown quantity at this point
As far as I know, then, your only real option is to use your PHP script to actually save an image file to your server (If you're in the situation described above). This isn't very hard...just use imagepng with the second argument as your filename. The only downside is that in order to regenerate your image, you'll have to re-run your script. You could do this manually or set up a cron job to do it automatically for you every so often.
bacterozoid is offline   Reply With Quote
Old 09-09-2009, 09:37 PM   PM User | #8
Blockis
New Coder

 
Join Date: Sep 2009
Posts: 36
Thanks: 4
Thanked 0 Times in 0 Posts
Blockis is an unknown quantity at this point
Very true.

Blockis
Blockis is offline   Reply With Quote
Old 09-09-2009, 10:08 PM   PM User | #9
Blatch
New Coder

 
Join Date: Mar 2003
Location: USA
Posts: 99
Thanks: 24
Thanked 0 Times in 0 Posts
Blatch is an unknown quantity at this point
I can easily have the image update itself every hour or so, but how can I go about writing this code? I'm new to gd.
Blatch is offline   Reply With Quote
Old 09-09-2009, 11:22 PM   PM User | #10
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,045
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
We'll need to see the image and what you want to write on it.
So an example of both the blank image and one with text so we know
what it's supposed to look like.
mlseim is offline   Reply With Quote
Old 09-10-2009, 12:08 AM   PM User | #11
Blatch
New Coder

 
Join Date: Mar 2003
Location: USA
Posts: 99
Thanks: 24
Thanked 0 Times in 0 Posts
Blatch is an unknown quantity at this point


It should write above it "Total Banners: X"
X a variable called from the number of rows in a table of my database.
Blatch is offline   Reply With Quote
Old 09-10-2009, 01:29 AM   PM User | #12
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,045
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
Here's my shot at it.

Tough to write that much text on your tiny image, but here it is ....

http://www.catpin.com/banner/
mlseim is offline   Reply With Quote
Users who have thanked mlseim for this post:
Blatch (09-10-2009)
Old 09-10-2009, 02:28 AM   PM User | #13
Blatch
New Coder

 
Join Date: Mar 2003
Location: USA
Posts: 99
Thanks: 24
Thanked 0 Times in 0 Posts
Blatch is an unknown quantity at this point
Hey, that's awesome!! That's almost exactly what I'm looking for. Thanks!

Now I'm wondering how I can make banner.png display that text? Instead of banner.php.
Blatch is offline   Reply With Quote
Old 09-10-2009, 02:46 AM   PM User | #14
Zangeel
Regular Coder

 
Zangeel's Avatar
 
Join Date: Oct 2007
Location: public_html/
Posts: 638
Thanks: 17
Thanked 79 Times in 79 Posts
Zangeel will become famous soon enough
I never tried it, but Mod Rewrite with a .htaccess file might be able to do it. It has the ability to rewrite urls and even extensions to urls so you may be able to rewrite the .php file to .png
__________________
PHP Code:
$aString is_string((string)array()) ? true false// true :D 
[/CENTER]
Zangeel is offline   Reply With Quote
Old 09-11-2009, 02:46 AM   PM User | #15
Blatch
New Coder

 
Join Date: Mar 2003
Location: USA
Posts: 99
Thanks: 24
Thanked 0 Times in 0 Posts
Blatch is an unknown quantity at this point
I know it can be done without that.

I need this to provide full functionality. You can't always use .php extensions on forums.
Blatch is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:58 PM.


Advertisement
Log in to turn off these ads.