PHP for current/min/max thermometer image from clientraw.txt

thanks so much Ken!!! It worked. Can’t believe how awesome these scripts are. I’ll continue to update my website till i get it right.

Again - thank you.

John

You’re very welcome, John! I’m very pleased you’ve found the template/scripts useful for your website.

Best regards,
Ken

This is a very cool piece of programming. I realise I have a lot to learn - but I would love to understand how this is done.

Its a PHP file and a lot of the code looks like PHP but what is the code that does the drawing itself - the actual red line - can someone give me some clues so I can read up about it and try and understand it??

Thanks very much

thermometer.php is a PHP script that returns a PNG image (instead of HTML) when it is run. It uses the GD library image drawing functions to

  1. load a background image (thermometer-blank.png)
  2. scale positions to pixel x,y offsets, draw tick marks on the background image,
  3. draw a filled rectangle (in red) where the thermometer ‘liquid’ should be,
  4. ‘print’ to the image the minimum, maximum temperature and units used on the background image,

then it returns the resulting image to the browser for display as image type=“image/png”

Another script set that uses the GD image drawing functions is Anoles Weather Graphic function which provides banner/graphic in many of the signatures on this forum. Other GD-based scripts like JPgraph allow you to draw gauges/plots/charts in a similar way.

The key things to remember for any PHP script that creates a graphic image are:

  1. the script must start with <?php as the first characters in the file, and end with ?> as the last characters in the file, with no blank lines or spaces before or after those markers. Otherwise, PHP will send a header saying the type is text/html instead of the script sending a type of image/png
  2. the script has to be invoked from an statement in the page to be displayed on the browser correctly.

Hope this helps…
Best regards,
Ken

Thats really helpful. Thanks Ken.

It look like the GD library is really useful - Ive looked it up on the web - and not too hard to use

Could it be used to move more complex images (.gifs or .pngs) on the webpage in response to weather data? Imagine an image of a cloud floating in a position on the page that represents cloud height for example…

You can use GD to create and write an image as long as that image was invoked by a tag in the HTML of the page. You can’t easily move an image from it’s location on the page with PHP since the PHP runs before the page is sent to the browser, so you’d have to have a really big background image referred to in the HTML, and the PHP would have to write to that ‘canvas’. Keep in mind that images can’t be indexed like HTML text so using images to present information means the text content of the image is not searchable by search engines.

But you could do cloud height in a similar way to the thermometer, have a background image with a vertical scale and overlay a small cloud image positioned according to the cloud height value.

Here’s one I’ve done.
It gets a METAR and clientraw (or VWS wflash) and determines which cloud type to
insert onto the background and also raises the windsock according to the wind speed.
At nighttime it inserts the moon according to the moon phase adjusted to northern
or southern hemisphere. Switches between day and night backgrounds and also indicates
clouds with drizzle, rain, thunderstorms and snow. Indicates when its foggy or misty.
Can also switch the background according to the seasons. Can be either in metric or imperial.

View sample websites here:
http://www.bashewa.com/ (switch to Imperial to view ft)
http://www.cellstop.com.na/weather/live/index.html

METRIC IMPERIAL AUTUMN BG WINTER BG SPRING BG SUMMER BG

View conditions and METAR here: http://www.bashewa.com/cloud-base.php?html=1

That is so cool… I would like to be able to add that to my site here, if you would care to share…

Looks great. How do you implement Meta? Using only in your php or with WD? Asking because my Meta doesn’t work in WD.

Regards

Jose

Very interesting…very impressive…so is that all done with .php pretty much? Is the little triangle done with the GD library function for example??

It would be interesting to see the code and compare it with Kens thermometer…

No problem I’ll share as soon as I get some time to package it.
I’m still busy fine tuning it. It’s got to be plug and play.

I don’t use the METAR from WD. I get it myself from NOAA.
You can disable the METAR download but then you sit with the problem of not knowing
what your cloud conditions are for determining the cloud type when you don’t have a
solar/UV meter. You have the same problem at night time.

Yes it’s all done in PHP5 (GD2).
And yes the idea came from Ken’s thermometer but completely new.


It makes heavy use of transparent overlays. For instance there are 11 cloud type overlays and 34 day and night backgrounds to choose from. The windsock has 5 positions. There are 29 moon phases each for North and South. A future enhancement would be to place the moon according to it's height in the sky and don't show it if it's not visible. The script is multilingual too and has lots of other features as well. I plan to use the same script at a later stage to make dynamic icons for the dashboard.

Here are some more samples (1st one has all the available goodies like temp, baro etc.):

I don't use the METAR from WD. I get it myself from NOAA. You can disable the METAR download but then you sit with the problem of not knowing what your cloud conditions are for determining the cloud type when you don't have a solar/UV meter. You have the same problem at night time.

Sounds good. I do have a uv and solar meter but at nighttime they won’t work. Hope that I can get this information from NOAA for my area.

The new screenshots are great. Especially the implementation of temp, etc.

Hope you’ll release it soon. :slight_smile:

Regards

Jose

The Cloud Height Graphic discussion has moved here:
http://discourse.weather-watch.com/t/39869

Sorry Ken for letting it get out of hand.


By the way here are my versions of Ken's thermometer.

Bashewa,

How did you get your thermometer to show the graduating colors for temps? I like that a lot.

Thanks, John Sacrey :slight_smile:

I Like it too,
Looks great!!

Those look cool. I mean hot. I mean comfotable. Oh, you get it.

You can get the Gradient Thermometer here:
http://discourse.weather-watch.com/t/44293

Hello All,

I’ve been away from the weather forums and using the ajax scripts for a couple years and now trying to get back into it. I’m trying to get the thermometer to display using the thermometer.php script but no luck so far after following the suggestions in this post and others. At this point, when running the script, I get a message saying, " The image “http://whitsweb.com/thermometer.php” cannot be displayed because it contains errors. "

I can get the image to display running the png file directly but it will not display using the script either alone or when embedded in the ajax-dashboard.php when using the templates.

I would sure appreciate any help anyone could offer to solve this problem.

Thanks and best regards,

Randy

Hi Randy,

Change

//$wxSoftware = 'WD'; set the $clientrawfile

;

to

$wxSoftware = 'WD'; // set the $clientrawfile

and it should work fine.

Best regards,
Ken