Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    New Coder
    Join Date
    Mar 2003
    Location
    USA
    Posts
    99
    Thanks
    24
    Thanked 0 Times in 0 Posts

    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?

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,470
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    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).

  • #3
    Regular Coder bacterozoid's Avatar
    Join Date
    Jun 2002
    Location
    USA
    Posts
    490
    Thanks
    24
    Thanked 35 Times in 35 Posts
    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.

  • #4
    New Coder
    Join Date
    Mar 2003
    Location
    USA
    Posts
    99
    Thanks
    24
    Thanked 0 Times in 0 Posts
    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?

  • #5
    Regular Coder bacterozoid's Avatar
    Join Date
    Jun 2002
    Location
    USA
    Posts
    490
    Thanks
    24
    Thanked 35 Times in 35 Posts
    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?

  • #6
    New Coder
    Join Date
    Sep 2009
    Posts
    36
    Thanks
    4
    Thanked 0 Times in 0 Posts
    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

  • #7
    Regular Coder bacterozoid's Avatar
    Join Date
    Jun 2002
    Location
    USA
    Posts
    490
    Thanks
    24
    Thanked 35 Times in 35 Posts
    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.

  • #8
    New Coder
    Join Date
    Sep 2009
    Posts
    36
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Very true.

    Blockis

  • #9
    New Coder
    Join Date
    Mar 2003
    Location
    USA
    Posts
    99
    Thanks
    24
    Thanked 0 Times in 0 Posts
    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.

  • #10
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,470
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    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.

  • #11
    New Coder
    Join Date
    Mar 2003
    Location
    USA
    Posts
    99
    Thanks
    24
    Thanked 0 Times in 0 Posts


    It should write above it "Total Banners: X"
    X a variable called from the number of rows in a table of my database.

  • #12
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,470
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    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/

  • Users who have thanked mlseim for this post:

    Blatch (09-10-2009)

  • #13
    New Coder
    Join Date
    Mar 2003
    Location
    USA
    Posts
    99
    Thanks
    24
    Thanked 0 Times in 0 Posts
    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.

  • #14
    Regular Coder Zangeel's Avatar
    Join Date
    Oct 2007
    Location
    public_html/
    Posts
    638
    Thanks
    17
    Thanked 79 Times in 79 Posts
    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]

  • #15
    New Coder
    Join Date
    Mar 2003
    Location
    USA
    Posts
    99
    Thanks
    24
    Thanked 0 Times in 0 Posts
    I know it can be done without that.

    I need this to provide full functionality. You can't always use .php extensions on forums.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •