Please read the posts in the Announcements section about the current status of Cumulus development now that I have retired

Please read this post before posting

Latest Cumulus release v1.9.4 (build 1099) - Nov 28 2014
Latest Cumulus MX release - v3.0.0 build 3043 Jan 20 2017. See this post for download

Cumulus PHP-GD Avatar

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

Moderators: daj, TNETWeather

User avatar
beteljuice
Posts: 2469
Joined: Tue Dec 09, 2008 1:37 pm
Weather Station: None !
Operating System: XP SP3 - honest
Location: Dudley, West Midlands, UK

Re: Cumulus PHP-GD Avatar

Postby beteljuice » Tue Dec 22, 2009 12:20 am

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: 5192
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Stretch Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Cumulus PHP-GD Avatar

Postby mcrossley » Fri Apr 02, 2010 11:10 am

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?

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

Postby TNETWeather » Fri Apr 02, 2010 2:51 pm

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

User avatar
steve
Cumulus Author
Posts: 26654
Joined: Mon Jun 02, 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: Cumulus PHP-GD Avatar

Postby steve » Fri Apr 02, 2010 3:16 pm

I've changed the maximum to 100x100. You only had to ask, I had no idea!
Steve
-----
Hosting available for Cumulus web sites. See http://sandaysoft.com/forum/viewtopic.php?f=2&t=11876

Please read the posts in the Announcements section about the current status of Cumulus development since I have retired from my day job

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

Postby TNETWeather » Fri Apr 02, 2010 11:58 pm

Thought I had long time ago.
Kevin
Image
All you need is Time, Aptitude and Desire ... and you can build just about anything...

User avatar
phtvs
Posts: 96
Joined: Sat Dec 04, 2010 10:11 am
Weather Station: ws4000
Operating System: win7
Location: Lemmer

Re: Cumulus PHP-GD Avatar

Postby phtvs » Sat Jan 08, 2011 1:42 pm

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 Jun 17, 2011 7:43 pm
Weather Station: Davis Vantage Vue
Operating System: Windows XP SP3
Location: Wimborne Minster UK
Contact:

Re: Cumulus PHP-GD Avatar

Postby SpireWeather » Mon Jun 03, 2013 9:16 pm

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: 2469
Joined: Tue Dec 09, 2008 1:37 pm
Weather Station: None !
Operating System: XP SP3 - honest
Location: Dudley, West Midlands, UK

Re: Cumulus PHP-GD Avatar

Postby beteljuice » Mon Jun 03, 2013 9:42 pm

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 Jun 17, 2011 7:43 pm
Weather Station: Davis Vantage Vue
Operating System: Windows XP SP3
Location: Wimborne Minster UK
Contact:

Re: Cumulus PHP-GD Avatar

Postby SpireWeather » Tue Jun 04, 2013 5:52 am

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: 26654
Joined: Mon Jun 02, 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: Cumulus PHP-GD Avatar

Postby steve » Tue Jun 04, 2013 7:16 am

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
-----
Hosting available for Cumulus web sites. See http://sandaysoft.com/forum/viewtopic.php?f=2&t=11876

Please read the posts in the Announcements section about the current status of Cumulus development since I have retired from my day job

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

Re: Cumulus PHP-GD Avatar

Postby SpireWeather » Tue Jun 04, 2013 8:11 pm

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 Jun 11, 2008 7:36 pm
Weather Station: WMR-88
Operating System: Windows 8.1
Location: L'Estartit, Spain
Contact:

Re: Cumulus PHP-GD Avatar

Postby gwheelo » Tue Jun 04, 2013 9:24 pm

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 Jun 04, 2013 9:25 pm, edited 1 time in total.
Image

User avatar
steve
Cumulus Author
Posts: 26654
Joined: Mon Jun 02, 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: Cumulus PHP-GD Avatar

Postby steve » Tue Jun 04, 2013 9:25 pm

Sorry, it's me who's being dense. I thought it was the PHP banner we were talking about, and it's not.
Steve
-----
Hosting available for Cumulus web sites. See http://sandaysoft.com/forum/viewtopic.php?f=2&t=11876

Please read the posts in the Announcements section about the current status of Cumulus development since I have retired from my day job

User avatar
steve
Cumulus Author
Posts: 26654
Joined: Mon Jun 02, 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: Cumulus PHP-GD Avatar

Postby steve » Tue Jun 04, 2013 9:26 pm

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
-----
Hosting available for Cumulus web sites. See http://sandaysoft.com/forum/viewtopic.php?f=2&t=11876

Please read the posts in the Announcements section about the current status of Cumulus development since I have retired from my day job

User avatar
gwheelo
Posts: 453
Joined: Wed Jun 11, 2008 7:36 pm
Weather Station: WMR-88
Operating System: Windows 8.1
Location: L'Estartit, Spain
Contact:

Re: Cumulus PHP-GD Avatar

Postby gwheelo » Tue Jun 04, 2013 9:36 pm

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


Return to “Web site - General”

Who is online

Users browsing this forum: No registered users and 2 guests