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 3043 Jan 20 2017. See the Wiki 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
William Grimsley
Posts: 833
Joined: Thu 22 Sep 2011 5:22 pm
Weather Station: Davis Vantage Vue
Operating System: Windows 7 Home Premium 64-bit
Location: Latitude: 50.70189285 Longitude: -3.30849957
Contact:

Re: Cumulus PHP-GD Banner

Post by William Grimsley » Fri 01 Feb 2013 6:36 pm

Hi there,

Ok, first of all I've got these 2 bits of code in my banner.php:

As you can see, I've deleted the "wspeed" tag and added the "wlatest" tag. I thought this makes sense.

Code: Select all

// Current field names (matches tag fields) used
$SITE['cvalues'] = array(
    "date","time","temp","hum","dew","wlatest","wgust","avgbearing","rrate",
    "rfall","press","wdir","beaufort","windunit","tempunit","pressunit","rainunit",
    "windrun","presstrend","rmonth","ryear","rfallY","intemp","inhum","wchill",
    "temptrendval","tempTH","TtempTH","tempTL","TtempTL",
    "windTM","TwindTM","wgustTM","TwgustTM",
    "pressTH","TpressTH","pressTL","TpressTL",
    "cversion","cbuild");
Then, I added the same thing here. I changed the ("wspeed") tag to the ("wlatest") tag. I thought this makes sense.

Code: Select all

// Print windspeed
$text = "Wind: " . ret_value("wdir") . " " . ret_value("wlatest") . ' ' . ret_value("windunit");
if ($SITE['usettf'] == "yes" ) {
    $size = 10;
    imagettftextbox($im, $size, 0, 0, 22, $green, $font1, $text, $SITE['image_width'], "left");
} else {
    $size = 5;
    imageWriteString($im, $size, $text, $green, "left", 23);
}
But, then it just came up with the "wspeed" value instead of the "wlatest" value on my banner.php file. :(

Why has this happened?

Thanks

William

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 Banner

Post by steve » Fri 01 Feb 2013 7:35 pm

The script doesn't use web tags, it uses realtime.txt. It has no idea what 'wlatest' is unless you tell it. The labels you've changed are just identifiers for the fields in realtime.txt. In fact, what the script calls 'wgust' is actually the 'latest' wind speed.
Steve

User avatar
William Grimsley
Posts: 833
Joined: Thu 22 Sep 2011 5:22 pm
Weather Station: Davis Vantage Vue
Operating System: Windows 7 Home Premium 64-bit
Location: Latitude: 50.70189285 Longitude: -3.30849957
Contact:

Re: Cumulus PHP-GD Banner

Post by William Grimsley » Fri 01 Feb 2013 7:37 pm

Oh, right! Thanks, changing both tags from "wlatest" to "wgust", worked! :D

User avatar
avoorpool
Posts: 168
Joined: Tue 08 May 2012 4:24 pm
Weather Station: WMR200A
Operating System: Windows 10 64-bit
Location: Pickering, Ontario Canada
Contact:

Re: Cumulus PHP-GD Banner

Post by avoorpool » Sun 10 Feb 2013 6:59 pm

HI,

I'd like to add a setting to the banner (change Windchill to Apparent Temp).
The code shows realtime.txt fields & pos 0 to 39 however apptemp is not shown in the 'banner.php' script.

How and where do I add the apptemp (realtime.txt pos # 55) to the code so it will be displayed on the banner??

Thanks,

Arthur

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 Banner

Post by steve » Sun 10 Feb 2013 7:06 pm

You need to extend the 'cvalues' array so that it goes as far as the field you want. Then use whatever identifier you give to the field you want later on in the lines of code which write the data to the image.
Steve

User avatar
avoorpool
Posts: 168
Joined: Tue 08 May 2012 4:24 pm
Weather Station: WMR200A
Operating System: Windows 10 64-bit
Location: Pickering, Ontario Canada
Contact:

Re: Cumulus PHP-GD Banner

Post by avoorpool » Sun 10 Feb 2013 7:24 pm

Hi Steve,

Thanks for the reply.

This means I have to add the 'cvalues' positions 40 - 55 (as the realtime.txt currently shows)..??
According realtime.txt it's: '10 minute high gust' (#40) to 'Apparent Temp' (#55)

Thanks,

Arthur

User avatar
avoorpool
Posts: 168
Joined: Tue 08 May 2012 4:24 pm
Weather Station: WMR200A
Operating System: Windows 10 64-bit
Location: Pickering, Ontario Canada
Contact:

Re: Cumulus PHP-GD Banner

Post by avoorpool » Sun 10 Feb 2013 8:04 pm

Hi Steve,

Figured it out. Correct display now!! Thanks!!!

BTW: Thanks for the final version 1.9.3 as well. :clap:
Great!!

Cheers,

Arthur

User avatar
kingqueen
Posts: 60
Joined: Tue 26 Feb 2013 6:52 pm
Weather Station: Maplin N96GY / Fine Offset 1081
Operating System: Windows 7 HP 64 bit
Location: Wetherby, UK
Contact:

Re: Cumulus PHP-GD Banner

Post by kingqueen » Sun 10 Mar 2013 7:44 pm

I have been attempting to add a background image to my banner but have been struggling. I think it might be an issue with the palette used.

If I use this:
Image
Then, using these instructions I get this:
Image

But if I fade it and use this:
Image
I get a mess like this:
Image

The same if I use .png or .jpg - I still get a mess.

Any suggestions as to how to make this better would be very gratefully received! Thank you!
Image

User avatar
Werk_AG
Posts: 182
Joined: Sun 13 Jan 2013 8:04 pm
Weather Station: WeatherDuino Pro2
Operating System: Windows 7
Location: Cercal CDV - Portugal

Re: Cumulus PHP-GD Banner

Post by Werk_AG » Sun 10 Mar 2013 10:00 pm

Hi

Try to change this line of code in your banner.php:

Code: Select all

$im = @imagecreate($SITE['image_width'], $SITE['image_height'])
with this one:

Code: Select all

$im = @imagecreatetruecolor($SITE['image_width'], $SITE['image_height'])
Hope it helps
Image

User avatar
kingqueen
Posts: 60
Joined: Tue 26 Feb 2013 6:52 pm
Weather Station: Maplin N96GY / Fine Offset 1081
Operating System: Windows 7 HP 64 bit
Location: Wetherby, UK
Contact:

Re: Cumulus PHP-GD Banner

Post by kingqueen » Sun 10 Mar 2013 10:24 pm

That's got it. Thank you very much indeed, Werk_AG.
Image

nicp01
Posts: 26
Joined: Fri 25 Jan 2013 10:38 am
Weather Station: vantage pro 2
Operating System: windows 7
Location: United Kingdom

hloc where's the data

Post by nicp01 » Tue 02 Apr 2013 12:07 pm

Hi, hope someone can help ....get banner but no data which suggests path not right to realtime.txt
checkserver all ok

/home/linweb17/s/stpetersstonyhurst.org.uk-1063720548/user/htdocs/hgweather

what should the path for hloc be "./"; not working..

Thks Peter

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: hloc where's the data

Post by steve » Tue 02 Apr 2013 12:21 pm

Rats. I merged the topic and ended up with the title of the new one instead of the original. I should just leave things alone.

I'll see if I can fix.

Edit: sorted, I think.
Steve

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: hloc where's the data

Post by steve » Tue 02 Apr 2013 12:26 pm

nicp01 wrote:what should the path for hloc be "./"; not working..
The path is correct; the problem is that you have no realtime.txt file on your web site. The most likely cause is either that you haven't selected the realtime settings on the internet settings screen, or you haven't supplied the correct directory in the web site setup.
Steve

nicp01
Posts: 26
Joined: Fri 25 Jan 2013 10:38 am
Weather Station: vantage pro 2
Operating System: windows 7
Location: United Kingdom

Re: hloc where's the data

Post by nicp01 » Tue 02 Apr 2013 12:51 pm

steve wrote:
nicp01 wrote:what should the path for hloc be "./"; not working..
The path is correct; the problem is that you have no realtime.txt file on your web site. The most likely cause is either that you haven't selected the realtime settings on the internet settings screen, or you haven't supplied the correct directory in the web site setup.
I presumed because the site updates realtime.txt was there...

yes youre right I havent any of the realtime boxes checked, which ones do I need? Ive ticked all 3! ok realtime.txt is there but it still isnt working!! now it is!! thkyou

How do I attach my banner to say a yahoo email??

I can now get to work on the background img.

(1840 .. have copied/edited beteljuice code and put new bground img file into 3 different folders and still I get very small icon!)
(http://stpetersstonyhurst.org.uk/hgweather/banner.php)

Do you know if anybody's done a graphic of the weather station circle I used to plot many years ago?

thks
peter

1984
Posts: 1
Joined: Sat 27 Apr 2013 4:08 pm
Weather Station: wh1080
Operating System: server 2008 r2
Location: norfolk, uk

Cumulus PHP-GD Banner - What am I doing wrong...

Post by 1984 » Sat 27 Apr 2013 4:18 pm

Hello,

I am new to posting on this forum, been reading stuff for around a year.

I am stumped, i am trying to get the background image on my php banner, I currently have this in the code:


// Output the header to let the browser know we are
// sending a graphic file format
header("Content-type: image/" . $SITE['format'] );
$im = @imagecreate($SITE['image_width'], $SITE['image_height'])
or die("Cannot Initialize new GD image stream");

// Set colors we want to use...
// first background is a white background
$background_color = imagecolorallocate($im, 0xFF, 0xFF, 0xFF);
$black = imagecolorallocate($im, 0x00, 0x00, 0x00);
$green = imagecolorallocate($im, 0x00, 0x80, 0x00);
$blue = imagecolorallocate($im, 0x00, 0x00, 0xff);
$red = imagecolorallocate($im, 0xff, 0x00, 0x00);

$baseimg = imagecreatefromjpeg("background1.jpg");

imagecopy($im,$baseimg,0,0,0,0,$SITE['image_width'], $SITE['image_height']);
imagedestroy($baseimg);

// Make a Border Around the box


I have a 17KB file called background1.jpg in the /images folder, but all I get is the default white background, what daft thing am I missing?

Thanks in advance :)

Post Reply