Please read the posts in the Announcements section about the current status of Cumulus development now that I have retired

Please read this post before posting

Latest Cumulus release v1.9.4 (build 1099) - Nov 28 2014
Latest Cumulus MX release - v3.0.0 build 3043 Jan 20 2017. See this post for download

Cumulus PHP-GD Banner

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

Moderators: daj, TNETWeather

User avatar
TNETWeather
Posts: 663
Joined: Wed Sep 17, 2008 1:34 pm
Weather Station: Davis VP2 Plus w/24 FARS
Operating System: WinX Pro SP3 Dedicated wstn
Location: Mesa, AZ USA
Contact:

Cumulus PHP-GD Banner

Postby TNETWeather » Sun Oct 05, 2008 3:13 am

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.

Project Page and Downloads

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

Collection of other banners in use:

http://cumulus.tnetweather.com/projects/phpggbanner/gallery
Last edited by TNETWeather on Sun Oct 05, 2008 5:47 am, edited 1 time in total.
Kevin
Image
All you need is Time, Aptitude and Desire ... and you can build just about anything...

User avatar
TNETWeather
Posts: 663
Joined: Wed Sep 17, 2008 1:34 pm
Weather Station: Davis VP2 Plus w/24 FARS
Operating System: WinX Pro SP3 Dedicated wstn
Location: Mesa, AZ USA
Contact:

Re: Cumulus PHP-GD Banner

Postby TNETWeather » Sun Oct 05, 2008 3:47 am

Source Code:

The following will output the current source of the banner.php script:

TNET Cumulus Project Page
Kevin
Image
All you need is Time, Aptitude and Desire ... and you can build just about anything...

arthurhh
Posts: 63
Joined: Thu Sep 18, 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

Postby arthurhh » Sun Oct 05, 2008 4:26 am

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

IT Fixer

arthurhh
Posts: 63
Joined: Thu Sep 18, 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

Postby arthurhh » Sun Oct 05, 2008 4:42 am

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

IT Fixer

User avatar
TNETWeather
Posts: 663
Joined: Wed Sep 17, 2008 1:34 pm
Weather Station: Davis VP2 Plus w/24 FARS
Operating System: WinX Pro SP3 Dedicated wstn
Location: Mesa, AZ USA
Contact:

Re: Cumulus PHP-GD Banner

Postby TNETWeather » Sun Oct 05, 2008 8:03 am

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 Oct 05, 2008 6:30 pm, edited 1 time in total.
Kevin
Image
All you need is Time, Aptitude and Desire ... and you can build just about anything...

User avatar
TNETWeather
Posts: 663
Joined: Wed Sep 17, 2008 1:34 pm
Weather Station: Davis VP2 Plus w/24 FARS
Operating System: WinX Pro SP3 Dedicated wstn
Location: Mesa, AZ USA
Contact:

Re: Cumulus PHP-GD Banner

Postby TNETWeather » Sun Oct 05, 2008 6:28 pm

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

The link to the source is the same...

Source Code:

TNET Cumulus Project Page
Kevin
Image
All you need is Time, Aptitude and Desire ... and you can build just about anything...

TgT
Posts: 127
Joined: Thu Jun 26, 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

Postby TgT » Sun Oct 05, 2008 10:33 pm

I guess script works in CLI mode ?

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

User avatar
TNETWeather
Posts: 663
Joined: Wed Sep 17, 2008 1:34 pm
Weather Station: Davis VP2 Plus w/24 FARS
Operating System: WinX Pro SP3 Dedicated wstn
Location: Mesa, AZ USA
Contact:

Re: Cumulus PHP-GD Banner

Postby TNETWeather » Sun Oct 05, 2008 11:11 pm

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
Kevin
Image
All you need is Time, Aptitude and Desire ... and you can build just about anything...

TgT
Posts: 127
Joined: Thu Jun 26, 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

Postby TgT » Sun Oct 05, 2008 11:34 pm

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: 26318
Joined: Mon Jun 02, 2008 6:49 pm
Weather Station: None
Operating System: None
Location: On tour in Portugal
Contact:

Re: Cumulus PHP-GD Banner

Postby steve » Mon Oct 06, 2008 7:41 am

These TTF ones are very smart, I'm going to change mine when I get a minute :)
Steve
-----
Hosting available for Cumulus web sites. See http://sandaysoft.com/forum/viewtopic.php?f=2&t=11876

Please read the posts in the Announcements section about the current status of Cumulus development since I have retired from my day job

User avatar
Paul C
Posts: 372
Joined: Thu Jun 19, 2008 7:45 am
Weather Station: Davis VP2 with solar
Operating System: Windows 10
Location: Brampton, Cumbria, UK
Contact:

Re: Cumulus PHP-GD Banner

Postby Paul C » Wed Oct 08, 2008 10:03 am

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

User avatar
TNETWeather
Posts: 663
Joined: Wed Sep 17, 2008 1:34 pm
Weather Station: Davis VP2 Plus w/24 FARS
Operating System: WinX Pro SP3 Dedicated wstn
Location: Mesa, AZ USA
Contact:

Re: Cumulus PHP-GD Banner

Postby TNETWeather » Wed Oct 08, 2008 10:23 am

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...
Kevin
Image
All you need is Time, Aptitude and Desire ... and you can build just about anything...

User avatar
Paul C
Posts: 372
Joined: Thu Jun 19, 2008 7:45 am
Weather Station: Davis VP2 with solar
Operating System: Windows 10
Location: Brampton, Cumbria, UK
Contact:

Re: Cumulus PHP-GD Banner

Postby Paul C » Wed Oct 08, 2008 10:52 am

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

User avatar
TNETWeather
Posts: 663
Joined: Wed Sep 17, 2008 1:34 pm
Weather Station: Davis VP2 Plus w/24 FARS
Operating System: WinX Pro SP3 Dedicated wstn
Location: Mesa, AZ USA
Contact:

Re: Cumulus PHP-GD Banner

Postby TNETWeather » Wed Oct 08, 2008 10:58 am

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.
Kevin
Image
All you need is Time, Aptitude and Desire ... and you can build just about anything...

User avatar
steve
Cumulus Author
Posts: 26318
Joined: Mon Jun 02, 2008 6:49 pm
Weather Station: None
Operating System: None
Location: On tour in Portugal
Contact:

Re: Cumulus PHP-GD Banner

Postby steve » Wed Oct 08, 2008 11:42 am

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
-----
Hosting available for Cumulus web sites. See http://sandaysoft.com/forum/viewtopic.php?f=2&t=11876

Please read the posts in the Announcements section about the current status of Cumulus development since I have retired from my day job


Return to “Web site - General”

Who is online

Users browsing this forum: No registered users and 7 guests