View Full Version : Dynamic Image Countdown..
Jeffreyv1987
08-18-2010, 04:29 PM
How would I create a Dynamic Image with a countdown to an event on it??
djr33
08-18-2010, 04:55 PM
Can you fully explain the idea? I don't understand yet.
You posted this in the PHP section-- do you want this to occur every time the page loads, or do you want this to be a moving part of the page? PHP can only work once, each time the page loads (or reloads). You will need to use Javascript if you want this "moving" without reloading the page.
Jeffreyv1987
08-18-2010, 05:11 PM
I'd like it so users on my site can take it and use it as a forum signature I don't know if JavaScript can do that..
djr33
08-18-2010, 06:06 PM
Typically forums will not allow Javascript, but they will certainly not allow PHP. Do you want to host something on your site (an image?) that can be loaded in a signature?
Again, please fully explain what you want, perhaps with an example if you have one. What will happen and when...
Jeffreyv1987
08-18-2010, 06:57 PM
Yes I want to host an image on my site which has a countdown to a specific date on it, an can be used as a signature...
something like this.. http://i33.tinypic.com/11awrx0.jpg
Is that better or should i get more examples?
djr33
08-18-2010, 11:11 PM
Ah, now I understand.
What you will do is create an "image" that is actually a PHP file. This is a PHP file just like one that can generate HTML, but instead its output will be the image data.
You will use an image functions library like gd or image magick. Either will be fine, though they both are very slow at times and hard to use. For a simple and small image like that, however, it will not be too difficult.
What you will do is import an existing image, in that case the cat. Then you will use image_text() or a similar function to add text to the image, based on the current date. You can get this using the function date(), in any format you'd like.
Finally, you will use a function like imagejpeg() to output the image directly.
At the very beginning of your script, you must set the correct file format headers, so that the data is served as an image instead of text.
There should be plenty of information available by searching for either "gd" or "image magick". php.net will have information for any of the specific functions.
After that, all that they will need to do is add that link to their signature and it will automatically update whenever it's loaded.
Additionally, this will mean that your "image" has a .php extension. If you must use a .jpg or other image extension, you must force this using .htaccess to process the ".jpg" extension as a PHP file. This is, however, a terrible idea for ALL of your images, so do this only in a local subdirectory.
jscheuer1
08-19-2010, 02:51 AM
See also:
http://us3.php.net/manual/en/function.imagepng.php
Take note also of the wealth of image functions available with GD listed on the left side of the above page.
With these you can take just about any existing image, and using the date and other more basic PHP functions, slap on to it any countdown you like.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.