Page 2 of 4

Re: Cumulus PHP-GD Avatar

Posted: Tue 22 Dec 2009 12:20 am
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 !!

Re: Cumulus PHP-GD Avatar

Posted: Fri 02 Apr 2010 11:10 am
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?

Re: Cumulus PHP-GD Avatar

Posted: Fri 02 Apr 2010 2:51 pm
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.

Re: Cumulus PHP-GD Avatar

Posted: Fri 02 Apr 2010 3:16 pm
by steve
I've changed the maximum to 100x100. You only had to ask, I had no idea!

Re: Cumulus PHP-GD Avatar

Posted: Fri 02 Apr 2010 11:58 pm
by TNETWeather
Thought I had long time ago.

Re: Cumulus PHP-GD Avatar

Posted: Sat 08 Jan 2011 1:42 pm
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...

Re: Cumulus PHP-GD Avatar

Posted: Mon 03 Jun 2013 9:16 pm
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,

Re: Cumulus PHP-GD Avatar

Posted: Mon 03 Jun 2013 9:42 pm
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.

Re: Cumulus PHP-GD Avatar

Posted: Tue 04 Jun 2013 5:52 am
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.

Re: Cumulus PHP-GD Avatar

Posted: Tue 04 Jun 2013 7:16 am
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.

Re: Cumulus PHP-GD Avatar

Posted: Tue 04 Jun 2013 8:11 pm
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:

Re: Cumulus PHP-GD Avatar

Posted: Tue 04 Jun 2013 9:24 pm
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

Re: Cumulus PHP-GD Avatar

Posted: Tue 04 Jun 2013 9:25 pm
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.

Re: Cumulus PHP-GD Avatar

Posted: Tue 04 Jun 2013 9:26 pm
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.

Re: Cumulus PHP-GD Avatar

Posted: Tue 04 Jun 2013 9:36 pm
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