Ok, I can't diagnose the code but I have done some testing. The results might not help at all but, at least it appears that the image is (in theory) being created ok, it is just not being displayed..
In Chrome, F12, [url]html://
www.jerbils.info/wxtestit.php[/url] shows the following generated...
<img src="cloudbase.php?uom=I" alt="Cloud Base @ 1416 feet (ASL)" title="Cloud Base @ 1416 feet (ASL)" style="width: 100px; height: 200px; border: none;">
and what shows is a rectangle 100x200 in the page with the "broken image" icon in the center.
If you right click and select "open image in new tab" the url
http://www.jerbils.info/saratoga/cloudbase.php?uom=I is opened in a new tab and the broken image icon is displayed.
So, I made some mods under F12 to change the statement to...
<img src="cloudbase.php?uom=m&html=1" alt="Cloud Base @ 1416 feet (ASL)" title="Cloud Base @ 1416 feet (ASL)" style="width: 100px; height: 200px; border: none;">
I don't know, if doing so, whether you would expect the original page to change (it does when you change other items, like style info.) but it doesn't.
Now, of course?, if you right click and select "open image in new tab" the url
http://www.jerbils.info/saratoga/cloudb ... m=m&html=1 is opened in a new tab and the info is displayed as expected for the test "uom=m&html=1".
Also, if you right click the box with the broken image icon and "Save image as...", a jpg is downloaded but it is corrupted. That is because it isn't an image at all, it is a set of html code associated with the output of the test "uom=m&html=1".
If I modify the statement to read....
<img src="cloudbase.php?uom=m" alt="Cloud Base @ 1416 feet (ASL)" title="Cloud Base @ 1416 feet (ASL)" style="width: 100px; height: 200px; border: none;">
and right click the box with the broken image icon and "Save image as..." a jpg is downloaded and displays fine.
So, the image is being created fine (and, of course, I didn't need to do any of that testing as the proof of it is the presence of the cloudbase.jpg in the (saratoga) folder), it is just not being displayed (except when embedded in a piece of html, as in the "uom=m&html=1" test).
Googling the problem seems to imply that the main culprit is white space prior to and post the PHP open and close (<?php ?>) but it is obvious from the content of cloudbase.php that the authors were aware of this. Any other ideas?