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 4018) - 28 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 Avatar

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

Moderator: daj

TNETWeather

Cumulus PHP-GD Avatar

Post by TNETWeather »

Cumulus data generated Graphic Avatar

This is a simple PHP banner script that uses standard GD and the default fonts (5 of them), OR TrueType Fonts (you need to have both support and fonts available). The TTF are clearer and smoother looking.

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

Example is shown with TTF fonts ON (or set to yes).

Standard GD fonts or TTF Fonts

Control over which fonts the script will use is determined in the settings area with 2 settings:

Code: Select all

$SITE['fontdir']        = "fonts/";     # must contain ttf font files!
$SITE['usettf']         = "yes";        # Set to No to use default fonts
fontdir must point to a directory that contains the ttf fonts. To turn on the use of TTF fonts, you need to set usettf = yes.

I used 3 different fonts:

Code: Select all

// Path to our font file
$font1 = $SITE['fontdir'] . "arialbd.ttf";      # Arial Bold
$font2 = $SITE['fontdir'] . "arial.ttf";        # Arial
$font3 = $SITE['fontdir'] . "verdana.ttf";      # Verdana
If usettf = no, the script will use the 5 default fonts that come with GD.

The biggest difference is that with TTF fonts, you can use different sizes with the same font. GD fonts all 5 of them are different fonts at different sizes.

Usage:

The script is a single script that should work right out of the box (with TTF fonts turned off) if you place it in the same directory as where your realtime.txt file is being uploaded.

You will want to change the station name and the unit settings if you use different units for rain, temp wind and baro.

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

Settings:

The variables that can adjust the script are:

Code: Select all

############################################################################
# CONFIGURATION INFORMATION
############################################################################
$SITE['version']        = "0.1";
$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']    = 100;
$SITE['image_height']   = 100;
$SITE['sitename']       = "Mesa AZ USA";
$SITE['cumulusver']     = "1.8.2";
$SITE['tempunit']       = "°F";
$SITE['rainunit']       = "in";
$SITE['barounit']       = " mb";
$SITE['windunit']       = " mph";
This script is similar to the banner one, but I will be taking the new function that I added here to update the banner on shortly. This function works with TTF fonts and allows formatting control of Right, Center and Left formatting.

Project Page and Downloads

http://cumulus.tnetweather.com/projects/phpgdavatar
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 Avatar

Post by Paul C »

I even managed this first time !
Image
Paul C
Brampton, Cumbria, UK
117m ASL
http://www.bramptonweather.co.uk
Image
TNETWeather

Re: Cumulus PHP-GD Avatar

Post by TNETWeather »

.
Version 3.0 released

This version uses a new internal method to obtain the realtime.txt files and uses the new extended format.

You need to be using Cumulus 1.8.2 Beta or higher to use this version.

You can download the script from my project page (in my signature below).
User avatar
Jonsey
Posts: 112
Joined: Mon 05 Jan 2009 2:25 am
Weather Station: Fine Offset WH1081
Operating System: Shuttle Xpc SK41, XP Pro SP3
Location: Worsley, Manchester
Contact:

Re: Cumulus PHP-GD Avatar

Post by Jonsey »

How do you change the size of the text in the banner?

Dave
Image
User avatar
w5afw
Posts: 154
Joined: Thu 29 Jan 2009 8:48 pm
Weather Station: ws-2315
Location: Houston, the Eagle has landed, TX
Contact:

Re: Cumulus PHP-GD Avatar

Post by w5afw »

how might one incorporate a background image?
W5AFW, Lex

Image
gateway2capecod
Posts: 23
Joined: Sun 15 Feb 2009 8:22 pm
Weather Station: Davis Vantage Pro2
Location: West Wareham, Ma. USA
Contact:

Re: Cumulus PHP-GD Avatar

Post by gateway2capecod »

Hello..

both seem to be working here for banner and avatar...


Image


Image


I am not sure you can add a background image just yet....but will wait and see what Kevin has to say.

...chris
My Cumulus Site is Here: http://www.gateway2capecod.com/cumulus
My Main Site is here: http://www.gateway2capecod.com

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 Avatar

Post by steve »

w5afw wrote:how might one incorporate a background image?
I imagine you would use something like imagecopyresampled to copy from your chosen background image to your banner, before you start adding the other stuff on top.

Steve
User avatar
w5afw
Posts: 154
Joined: Thu 29 Jan 2009 8:48 pm
Weather Station: ws-2315
Location: Houston, the Eagle has landed, TX
Contact:

Re: Cumulus PHP-GD Avatar

Post by w5afw »

idea why this error on avatar?

Parse error: syntax error, unexpected ';' in /home/a5478673/public_html/av.php on line 68



http://wxnow.comli.com/av.php
W5AFW, Lex

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 Avatar

Post by steve »

w5afw wrote:idea why this error on avatar?

Parse error: syntax error, unexpected ';' in /home/a5478673/public_html/av.php on line 68
Hard to say without seeing the source code - have you modified it from the original?

Steve
User avatar
w5afw
Posts: 154
Joined: Thu 29 Jan 2009 8:48 pm
Weather Station: ws-2315
Location: Houston, the Eagle has landed, TX
Contact:

Re: Cumulus PHP-GD Avatar

Post by w5afw »

" have you modified it from the original?"

not intentionally /smile/

see attached (I added .txt so it would attach)
You do not have the required permissions to view the files attached to this post.
W5AFW, Lex

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 Avatar

Post by steve »

Code: Select all

if ( isset($_REQUEST['view']) && $_REQUEST['view'] == 'sce' ) {
You appear to have been using a web editor, or something else which has encoded some of the characters, those should be real ampersands. You have similar problems with ampersands and other encoded characters elsewhere in the file:

Code: Select all

for($i = 0; $i < count($words); $i++)

Code: Select all

 if($line_width > $max_width && !$first_word)
etc...

Steve
User avatar
w5afw
Posts: 154
Joined: Thu 29 Jan 2009 8:48 pm
Weather Station: ws-2315
Location: Houston, the Eagle has landed, TX
Contact:

Re: Cumulus PHP-GD Avatar

Post by w5afw »

Hmmm... I can't imagine how it got corrupted; using notepad... I'll try again from scratch. '
W5AFW, Lex

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 Avatar

Post by steve »

w5afw wrote:Hmmm... I can't imagine how it got corrupted; using notepad... I'll try again from scratch. '
Perhaps whatever you used to upload it, if you didn't use ftp? A 'helpful' web client?

Steve
User avatar
w5afw
Posts: 154
Joined: Thu 29 Jan 2009 8:48 pm
Weather Station: ws-2315
Location: Houston, the Eagle has landed, TX
Contact:

Re: Cumulus PHP-GD Avatar

Post by w5afw »

pretty strange. works now. thanks.
W5AFW, Lex

Image
User avatar
shamrockspider
Posts: 9
Joined: Sun 08 Mar 2009 6:55 am
Weather Station: WS1081
Operating System: Windows 10
Location: Auckland New Zealand
Contact:

Re: Cumulus PHP-GD Avatar

Post by shamrockspider »

steve wrote:
w5afw wrote:how might one incorporate a background image?
I imagine you would use something like imagecopyresampled to copy from your chosen background image to your banner, before you start adding the other stuff on top.

Steve
Try using imagecreatefromjpeg or imagecreatefromgif, or imagecreatefrompng depending on what format your desired background image is in having first created your desired background image the size of the banner you want and having placed it in the same directory as your banner.php.
See
http://uk2.php.net/manual/en/function.i ... omjpeg.php
http://uk2.php.net/manual/en/function.i ... romgif.php
http://uk2.php.net/manual/en/function.i ... rompng.php
Regards Kevin (Shamrockspider)
http://www.shamrockspider.com/wx/

Image
Post Reply