Welcome to the new home of the Cumulus Support forum.

Latest Cumulus release v1.9.4 (build 1099) - Nov 28 2014
Latest Cumulus MX release - v3.0.0 build 3044 7 December 2018. See the Wiki for download

Cumulus PHP-GD Avatar

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

Moderator: daj

User avatar
TNETWeather
Posts: 663
Joined: Wed 17 Sep 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 Avatar

Post by TNETWeather » Wed 08 Oct 2008 9:57 pm

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

User avatar
Paul C
Posts: 377
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 » Mon 13 Oct 2008 7:54 am

I even managed this first time !
Image

User avatar
TNETWeather
Posts: 663
Joined: Wed 17 Sep 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 Avatar

Post by TNETWeather » Mon 20 Oct 2008 1:07 am

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

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 » Wed 04 Mar 2009 11:47 pm

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 » Thu 05 Mar 2009 9:39 pm

how might one incorporate a background image?
W5AFW, Lex

Image

User avatar
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 » Fri 06 Mar 2009 7:35 am

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: 26714
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 » Fri 06 Mar 2009 8:15 am

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 » Mon 09 Mar 2009 7:25 am

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: 26714
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 » Mon 09 Mar 2009 8:11 am

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 » Mon 09 Mar 2009 1:32 pm

" 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: 26714
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 » Mon 09 Mar 2009 1:44 pm

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 » Mon 09 Mar 2009 2:02 pm

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: 26714
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 » Mon 09 Mar 2009 2:18 pm

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 » Mon 09 Mar 2009 2:48 pm

pretty strange. works now. thanks.
W5AFW, Lex

Image

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

Re: Cumulus PHP-GD Avatar

Post by shamrockspider » Mon 21 Dec 2009 11:14 pm

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