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 Avatar

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

Moderator: daj

User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Cumulus PHP-GD Avatar

Post by beteljuice »

Just to cover shamrockspiders solution, a couple of belts 'n' braces.

1/ Create the (background) image in the size and format of your choice.

2/ Modify the code in your banner.php to the following ...

Code: Select all


// Output the header to let the browser know we are
// sending a graphic file format
header("Content-type: image/" . $SITE['format'] );
$im = @imagecreatetruecolor($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, 0xC1, 0xFF, 0xC1);
$black              = imagecolorallocate($im, 0x00, 0x00, 0x00);
$green              = imagecolorallocate($im, 0x00, 0x80, 0x00);
$blue               = imagecolorallocate($im, 0x00, 0x00, 0x99);
$red                = imagecolorallocate($im, 0xff, 0x00, 0x00);
$indianred          = imagecolorallocate($im, 0x8b, 0x3a, 0x3a);

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

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

// Make a Border Around the box

Take care to use the correct imagecreatefrom...( for the format of your supplied background), and provide the correct filename ! (Doesn't have to be the same as the output image format)

Note the use of .. $im = @imagecreatetruecolor($SITE ...

This is a blank canvass we create to put your background on top. This ensures that if you copy from an image with less than 16mill colours, that all your text colour declarations still give the colours you expect !!
Image
......................Imagine, what you will KNOW tomorrow !
User avatar
mcrossley
Posts: 12689
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Cumulus PHP-GD Avatar

Post by mcrossley »

Just to dig up an old thread... I seem to be the only one actually using a live Avatar on the forum, everyone else is using banners, any reason why?
TNETWeather

Re: Cumulus PHP-GD Avatar

Post by TNETWeather »

Most likely because the Avatar is sized at 100x100 and the forum only supports up to 90x90.

It is not hard to change it, but the data ends up looking a bit cramped.

I use the Avatar on a number of other weather and non-weather forums which use the more standard 100x100 avatar sizes.
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 »

I've changed the maximum to 100x100. You only had to ask, I had no idea!
Steve
TNETWeather

Re: Cumulus PHP-GD Avatar

Post by TNETWeather »

Thought I had long time ago.
User avatar
phtvs
Posts: 96
Joined: Sat 04 Dec 2010 10:11 am
Weather Station: ws4000
Operating System: win7
Location: Lemmer

Re: Cumulus PHP-GD Avatar

Post by phtvs »

Hi,

I had this problem that most sites wont accept a .php file as avatar.

So I inserted this lines into the code:

Code: Select all

$dest = "avatar.gif";
imagegif($im,$dest);
$filename = $dest;
Put this code in the avatar script before the lines:

Code: Select all

// We be done... destroy the image
imagedestroy($im);

exit;
This save the avatar to your server disk as avatar.gif
Now you can use the avatar.gif instead of avatar.php.
http://www.linktoyoursite/xxxx/avatar.gif
(Change xxx to the location of your avatar script)

Make use of the fantastic Cumulus toolbox to execute the avatar script once an hour.
So now you have an avatar.gif with fresh data on it every hour!!!!

It also is possible to make use of cronjob to refrsh the data on the avatar more often!

Of course this also works for the banner.php script ;-)

Sorry for the bad english...
User avatar
SpireWeather
Posts: 58
Joined: Fri 17 Jun 2011 7:43 pm
Weather Station: Davis Vantage Vue
Operating System: Windows XP SP3
Location: Wimborne Minster UK
Contact:

Re: Cumulus PHP-GD Avatar

Post by SpireWeather »

Is it possible to add strings to the script other than those listed within?

I would like my avatar to include max, min temperature and pressure trend.

Here is my current avatar, used as a graphic in the sidebar of my website...

http://www.spireweather.co.uk/avatar-1.0.php

Thanks in advance,
Simon, WessexWeather
Image
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Cumulus PHP-GD Avatar

Post by beteljuice »

Anything that is in realtime.txt (or can be calculated from it) AND THE FIELD IS DEFINED WITHIN THE SCRIPT can be displayed.
Image
......................Imagine, what you will KNOW tomorrow !
User avatar
SpireWeather
Posts: 58
Joined: Fri 17 Jun 2011 7:43 pm
Weather Station: Davis Vantage Vue
Operating System: Windows XP SP3
Location: Wimborne Minster UK
Contact:

Re: Cumulus PHP-GD Avatar

Post by SpireWeather »

Thanks for your reply beteljuice. I am not familiar with php and cannot obviously work out how to define a new parameter. I can see the list of variables but not the tags they use. Can you help me out with, say defining a new variable for for pressure trend? I am sure I can then work out the rest.

Many thanks.
Simon, WessexWeather
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 »

SpireWeather wrote:I can see the list of variables but not the tags they use. Can you help me out with, say defining a new variable for for pressure trend? I am sure I can then work out the rest.
You don't need to define new ones for the ones you want, they are already there. To get the pressure trend value, use ret_value("presstrend"). If you want a descriptive form of the trend value, you would have to add some PHP which translated the value into the appropriate text. Today's high temperature is ret_value("tempTH"), and so on.

If you want to use any items in realtime.txt beyond the build number, you would need to extend the cvalues array in the script.
Steve
User avatar
SpireWeather
Posts: 58
Joined: Fri 17 Jun 2011 7:43 pm
Weather Station: Davis Vantage Vue
Operating System: Windows XP SP3
Location: Wimborne Minster UK
Contact:

Re: Cumulus PHP-GD Avatar

Post by SpireWeather »

Thanks for your reply Steve,

However I am a bit lost! I cannot find which part of avatar-1.0.php to edit...

Sorry for being so dense! :bash:
Simon, WessexWeather
Image
User avatar
gwheelo
Posts: 453
Joined: Wed 11 Jun 2008 7:36 pm
Weather Station: WMR-88
Operating System: Windows 8.1
Location: L'Estartit, Spain
Contact:

Re: Cumulus PHP-GD Avatar

Post by gwheelo »

Anybody know how to add either the Avatar or the Banner as a signature in gmail with it appearing as a link to my Cumulus "Home" page. I know how to cut and paste - I want it automated.

gwheelo
Last edited by gwheelo on Tue 04 Jun 2013 9:25 pm, edited 1 time in total.
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 »

Sorry, it's me who's being dense. I thought it was the PHP banner we were talking about, and it's not.
Steve
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 »

gwheelo wrote:Anybody know how to add either the Avatar or the Banner as a signature in gmail with it appearing as a link to my Cumulus "Home" page. I know how to cut and paste - I want it automated.
Are you sure you want to do that? As Kevin has pointed out before, it's a good way to get your emails blocked for suspicious content.
Steve
User avatar
gwheelo
Posts: 453
Joined: Wed 11 Jun 2008 7:36 pm
Weather Station: WMR-88
Operating System: Windows 8.1
Location: L'Estartit, Spain
Contact:

Re: Cumulus PHP-GD Avatar

Post by gwheelo »

Are you sure you want to do that?
Had not thought of that - good point - I am quickly changing my mind.

Thanks Steve,

gwheelo
Image
Post Reply