Welcome to the Cumulus Support forum.

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Cumulus MX V4 beta test release 4.0.0 (build 4017) - 17 March 2024

Legacy Cumulus 1 release v1.9.4 (build 1099) - 28 November 2014 (a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

Cumulus PHP-GD Banner

Other discussion about creating web sites for Cumulus that doesn't have a specific subforum

Moderator: daj

Post Reply
TNETWeather

Cumulus PHP-GD Banner

Post by TNETWeather »

Cumulus data generated Graphic Banner

I played around a bit with some of the existing banner php scripts out there and got them to work, but ended up just writing one from scratch. This is basically because the other scripts have lots of stuff in them that would not be supported and it will be easier to just build from this one.

This is a simple PHP banner script that uses standard GD and the default fonts (5 of them) that come with the package. I tested this on a PHP5 based server, so I'm not sure if it will work with PHP4.

This script generates an image each time it is called by reading the current realtime.txt file that is on the server.

Sample Output:

Image

It was very kind of Mother Nature to drop some rain so that I could for the first time test Cumulus's recording of rain...

The script is a single script, needs no images to work and uses standard GD (no ttf fonts).

If the script is used in the same web directory that your realtime.txt file is located, you won't need to make any changes except if you use different units for temp, rain, wind and of course you will want to change the station name to yours.

The version number which is not send out in the realtime.txt file is also a manual setting in the script.

Source and PDF Instructions

Unfortunately the original Coder of this banner (Kevin Reed) passed away in 2018 and his website was closed so the links below no longer work. I had backup copies of the source an instructions which I have made available in the topic below.

viewtopic.php?p=164850#p164850

Details below are no longer valid but I have left the topic intact in case there are any comments by other Users that help in the implementation.

Project Page and Downloads

http://cumulus.tnetweather.com/projects/phpggbanner

Collection of other banners in use:

http://cumulus.tnetweather.com/projects ... er/gallery
Last edited by TNETWeather on Sun 05 Oct 2008 5:47 am, edited 1 time in total.
arthurhh
Posts: 63
Joined: Thu 18 Sep 2008 8:40 pm
Weather Station: Davis VP pro 2
Operating System: Win7
Location: Tokoroa South Waikato New Zealand
Contact:

Re: Cumulus PHP-GD Banner

Post by arthurhh »

Many thanks, very easy to understand and use/modify
http://tokoroa.dyndns.org/ Main Site

IT Fixer
arthurhh
Posts: 63
Joined: Thu 18 Sep 2008 8:40 pm
Weather Station: Davis VP pro 2
Operating System: Win7
Location: Tokoroa South Waikato New Zealand
Contact:

Re: Cumulus PHP-GD Banner

Post by arthurhh »

http://tokoroa.dyndns.org/ Main Site

IT Fixer
TNETWeather

Re: Cumulus PHP-GD Banner

Post by TNETWeather »

See Version 1.1... this article has been superseded...

The new version allows you to choose this option in the source code.

One big advantage is that you can use more fonts and more importantly, you can change the size of the same font bigger (the temp) and smaller. The TTF fonts are also clearer in output than the default fonts.

The only issues is that you need to have support for TTF (possible show stopper for some) and of course you need some TTF fonts available on the server (not a big deal).

I've seen some code that allows dealing with flush right, left, center etc.. that would make positioning better. Will play with that tomorrow. Need to add some color shifts based on values as well (around here if it is > 100F, the font gets red, below say 32F blue etc...
Last edited by TNETWeather on Sun 05 Oct 2008 6:30 pm, edited 1 time in total.
TNETWeather

Re: Cumulus PHP-GD Banner

Post by TNETWeather »

Version: 1.1

Updated version supports both TTF and Default GD fonts.

If you want to use TTF fonts, you need to set the following variables:

Code: Select all

$SITE['fontdir']		= "fonts/";		# must contain ttf font files!
$SITE['usettf']			= "yes";		# Set to No to use default fonts
The fontdir needs to point to a directory that contains the Truetype fonts you want to use.

I simply copied over a number of fonts I use from time to time with JpGraph:

Code: Select all

-rw-r--r--   1 root     root       16880 Oct  5 00:11 ARIALALS.TTF
-rw-r--r--   1 root     root       24264 Oct  5 00:11 ARIALALT.TTF
-rw-r--r--   1 root     root      288496 Oct  5 00:11 arialbd.ttf
-rw-r--r--   1 root     root      226748 Oct  5 00:11 arialbi.ttf
-rw-r--r--   1 root     root      207808 Oct  5 00:11 ariali.ttf
-rw-r--r--   1 root     root      138468 Oct  5 00:11 ARIALNBI.TTF
-rw-r--r--   1 root     root      139056 Oct  5 00:11 ARIALNB.TTF
-rw-r--r--   1 root     root      134188 Oct  5 00:11 ARIALN.TTF
-rw-r--r--   1 root     root      311636 Oct  5 00:11 arial.ttf
-rw-r--r--   1 root     root      132832 Oct  5 00:11 comic.ttf
-rw-r--r--   1 root     root       49788 Oct  5 00:11 STENCIL.TTF
-rw-r--r--   1 root     root      137616 Oct  5 00:11 verdanab.ttf
-rw-r--r--   1 root     root      155076 Oct  5 00:11 verdanai.ttf
-rw-r--r--   1 root     root      171792 Oct  5 00:11 verdana.ttf
-rw-r--r--   1 root     root      154800 Oct  5 00:11 verdanaz.ttf
-rw-r--r--   1 root     root       37812 Oct  5 00:11 WEATHER.TTF
Further down in the code, you can see where I setup of the use of $font1 $font2 and $font3 like:

Code: Select all

// Path to our font file
$font1 = $SITE['fontdir'] . "arialbd.ttf";
$font2 = $SITE['fontdir'] . "arial.ttf";
$font3 = $SITE['fontdir'] . "verdana.ttf";
Also added logic that if there is no rain, to say No Rain Today instead of Rain 0.00xxx
TgT
Posts: 132
Joined: Thu 26 Jun 2008 5:51 am
Weather Station: Davis VP2 + Solar
Operating System: A20 TV box + CumulusMX
Location: Slov.Konjice, Slovenia
Contact:

Re: Cumulus PHP-GD Banner

Post by TgT »

I guess script works in CLI mode ?

Im going to try it out when I get time, nice work TNETWeather Respect :mrgreen:
Image
TNETWeather

Re: Cumulus PHP-GD Banner

Post by TNETWeather »

You could use it in CLI mode.

One way out of the box would be to call the script like:

Code: Select all

# path_to_php/php banner.php > banner.png
If you want to do that though, you should change the output commands and add a filename you want it saved as:

For example:

Code: Select all

imagegif($im, "banner.gif");
Then when the script is called, instead of outputting the image data, it would save it to a file instead.

Code: Select all

# path_to_php/php banner.php
TgT
Posts: 132
Joined: Thu 26 Jun 2008 5:51 am
Weather Station: Davis VP2 + Solar
Operating System: A20 TV box + CumulusMX
Location: Slov.Konjice, Slovenia
Contact:

Re: Cumulus PHP-GD Banner

Post by TgT »

Great! Got it working :D
Since im not that much in PHP coding what should i change so date will be shown as 06.10.08 instead of 08-10-06 :oops:

Thanks in advance!

EDIT: OK nevermind, i fixed it ;)
Image
User avatar
steve
Cumulus Author
Posts: 26702
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: Cumulus PHP-GD Banner

Post by steve »

These TTF ones are very smart, I'm going to change mine when I get a minute :)
Steve
User avatar
Paul C
Posts: 538
Joined: Thu 19 Jun 2008 7:45 am
Weather Station: Davis VP2 with solar
Operating System: Windows 10
Location: Brampton, Cumbria, UK
Contact:

Re: Cumulus PHP-GD Banner

Post by Paul C »

Kevin

As you can see I use a similar banner at the moment, but would like to switch to the cumulus version. You will have to bare with me or is it bear never can remember. Are there some simple instructions on how to use it/alter it. I have mine installed but completley forgot how to do it - Are there any of those smaller avatars available aswell and last question can any of these banners/scripts etc be use as a footer or signature on an email using Miscrosoft Outlook.

eg of the avatar - http://www.bramptonweather.co.uk/wd/wxg ... ype=avatar

How about a cumulus rapid fire weather - likes wundergrounds but one created for cumulus users as a stand alone system ?

http://www.wunderground.com/swf/Rapid_F ... =ICUMBRIA1

I always have great ideas, but now a clue how to do carry them out

thanks :D
Paul C
Brampton, Cumbria, UK
117m ASL
http://www.bramptonweather.co.uk
Image
TNETWeather

Re: Cumulus PHP-GD Banner

Post by TNETWeather »

Currently, the banner does just one banner output.

The banner you are currently using does have a lot of flexibility in it and in fact, I first hacked that script to make it work with Cumulus. However, the current realtime.txt is much less than what that script is capable of supporting so it was easier to just start over.

I have planned on either making the current script output multiple sized banners or simply creating a new script called... avatar.php. In fact, I almost started playing with that last night (its 3:19am here now), I am watching a server that paged me to see if it is okay.

As for using it, it is almost ready to work right out of the box er... download. It is assumed that you have PHP5 and have GD support included otherwise it won't work. You would need to adjust the information header information so that I knows about information that is not contained within the realtime.txt data file like station name, what unit values are used etc...

Code: Select all

############################################################################
# CONFIGURATION INFORMATION
############################################################################
$SITE['version']        = "1.4";
$SITE['hloc']           = "./";
$SITE['datafile']       = "realtime.txt";
$SITE['fontdir']        = "fonts/";     # must contain ttf font files!
$SITE['usettf']         = "yes";         # Set to No to use default fonts
$SITE['format']         = "png";        # Options: jpeg  gif  png 
$SITE['dateiso']        = "no";
$SITE['image_width']    = 468;
$SITE['image_height']   = 60;
$SITE['sitename']       = "Mesa AZ USA - TNET Weather";
$SITE['cumulusver']     = "1.8.2";
$SITE['tempunit']       = "°F";
$SITE['rainunit']       = "in";
$SITE['barounit']       = " mb";
$SITE['windunit']       = " mph";
For most, it doesn't appear to have been too hard to setup especially if you place it in the same directory that the realtime.txt file is located.

Changing the colors, sizes and position, does require some tweaking, but that part is not that dissimilar to the script you are already using.

I think that before I start either adding more formats or creating a new script to do that, I want to come up with some basic functions that make formatting a bit easier. Like the ability to specify flush right, left and center so that changing values remain positioned correctly. There are some functions out there that do that now, I just haven't given them a try yet.

As for your last request... I'm not a flash programmer... though I have started to dabble a bit. I would have a better shot at perhaps an AJAX based web page that does the same.

But before I start down that road, I want to finish the XML stuff as that would then provide a lot more data about the station than just what the realtime.txt file provides. And I currently upload the test XML file once a minute now.

Note that I'm not a big fan of rapid data uploads.... which primarily just show wind changes. I personally, don't have too much time to sit and watch my weather output for hours on end.

Having the XML data available to the banner script would greatly increase the data that could be displayed as well, such as current conditions, historical data like monthly, yearly rain, current cumulus version etc... data that is not contained in the realtime.txt file

I only have so much time to play though...
User avatar
Paul C
Posts: 538
Joined: Thu 19 Jun 2008 7:45 am
Weather Station: Davis VP2 with solar
Operating System: Windows 10
Location: Brampton, Cumbria, UK
Contact:

Re: Cumulus PHP-GD Banner

Post by Paul C »

Thanks for the reply at 0315hrs !! If its any consolation I will be working until 2am tomorrow :D

I will give it a go over the next few days and let you know if I succeed.

I take it I keep using what I have already alongside the new cumulus one ?

cheers
Paul C
Brampton, Cumbria, UK
117m ASL
http://www.bramptonweather.co.uk
Image
TNETWeather

Re: Cumulus PHP-GD Banner

Post by TNETWeather »

Paul C wrote:I will give it a go over the next few days and let you know if I succeed.
I think you will find it is really easy to use. You should be able to put it on your server and run it without any changes and you will get output. You can then tweak it from there.
I take it I keep using what I have already alongside the new cumulus one ?
There should not be any issues as to how many of these types of things you have on your server other than keeping track of which does which.
User avatar
steve
Cumulus Author
Posts: 26702
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: Cumulus PHP-GD Banner

Post by steve »

I've been meaning to ask you - I tried to use my banner on another forum, and it said php wasn't allowed for images. Is there a way around this?
Steve
TgT
Posts: 132
Joined: Thu 26 Jun 2008 5:51 am
Weather Station: Davis VP2 + Solar
Operating System: A20 TV box + CumulusMX
Location: Slov.Konjice, Slovenia
Contact:

Re: Cumulus PHP-GD Banner

Post by TgT »

Post Reply