cloudy

Author Topic: New Script: Text Overlay Web Cam Image from PHP Weather-Display tags  (Read 29248 times)

0 Members and 1 Guest are viewing this topic.

Offline MCHALLIS

  • Posts: 2,102
  • Long Beach, WA USA
    • Weather for Long Beach, WA USA
You can use my new Multifunction Image Handler PHP Script as a Webcam Text Overlay PHP Script

Here is how to use it to overlay text from your weather data

Step 1) Install Ken True's PHP Weather-Display tags feature
http://saratoga-weather.org/scripts.php#PHPtags
Configure WD to upload the testtags.php to your web server every 5 minutes.
The testtags.php will have the weather variables you can use on your web cam overlay text
If you are already using the Weather Display/PHP/AJAX Website Template Set then you can skip this step.

Step 2) Install my Multifunction Image Handler PHP Script
http://www.642weather.com/weather/scripts.php
Just download the file, adjust a few settings at the top, upload it to your web server, and link to the file like you would an image. Please refer to the "How to use it" section at the top of the script source code for all the details.
Make sure step 2 is working, then continue to step 3.

Step 3) Edit the Multifunction Image Handler PHP Script file
In the settings section at the top make this simple change ...

change

Code: [Select]
$text1 = '';

to

Code: [Select]
# Relative path to your testtags.php file, Not the URL. (use ./testtags.php if it is in the same directory.)
require "./testtags.php";
$timezone = date('T');
$temperature = preg_replace('/°F/', ' °F', $temperature);

$text1 = "$time $timezone $date
$temperature, Rain:$dayrn, Wind:$avgspd, Max Gust:$maxgst
$current_summary
Long Beach, WA
www.642weather.com";

Use double quotes for the php variables to display.
The text can be a single line or multiple lines. If the line is too long it will auto wrap.
You can modify the text to your liking and use any data variables you want from the testtags.php file

See a live demo of it here:
Demo - Multifunction Image Handler
http://www.642weather.com/weather/scripts-image-handler.php#IHdemo

New Tutorials online:

PHP Web Cam Image Text Overlay Tutorial by Mike Challis
http://www.642weather.com/weather/scripts-weather-cam-text.php

How To PHP Upload Your Web Cam Image to WeatherUnderground
http://www.642weather.com/weather/scripts-weather-cam-uploader.php
« Last Edit: December 17, 2008, 04:38:31 AM by MCHALLIS »

Offline niko

  • syzygy
  • Global Moderator
  • Posts: 21,997
  • Crystal Ball broken! Please post the URL.
  • Northern California, U.S.A.
    • http://www.realweatherstation.com
Re: New Script: Text Overlay Web Cam Image from testtags.php Data
« Reply #1 on: January 07, 2008, 03:12:37 AM »
Good one :thumbright:

Online saratogaWX

  • Posts: 4,556
  • Saratoga, CA, USA 37:16:28N, 122:01:23W - Elev: 374ft.
    • Saratoga Weather
Re: New Script: Text Overlay Web Cam Image from PHP Weather-Display tags
« Reply #2 on: January 07, 2008, 06:42:52 AM »
Very cool, Mike!   :D/ =D> :greenjumpers:

Congratulations on starting your own "scriptorium"!

Best regards,
Ken
Ken True
Saratoga Weather
CWOP: CW1792
WeatherUnderground: KCASARAT1
Free weather website PHP scripts and WD website AJAX templates

Offline smokie

  • Posts: 309
  • WS2300 operational May 2007
  • Newquay, Cornwall UK
    • Newquay cams and weather
Re: New Script: Text Overlay Web Cam Image from PHP Weather-Display tags
« Reply #3 on: January 08, 2008, 02:46:46 PM »
Hi, cool script, good job, one thing I must be missing something becasue altering the $textalign to any of the other options has no effect, the overlay still appears top left, any ideas, works great apart from that.

« Last Edit: January 08, 2008, 02:48:43 PM by smokie »

Newquay, Cornwall.UK  > WS2300 Operational since May 2007.
From 6/4/08 www.newquayweather.com
** Philip

Offline MCHALLIS

  • Posts: 2,102
  • Long Beach, WA USA
    • Weather for Long Beach, WA USA
Re: New Script: Text Overlay Web Cam Image from PHP Weather-Display tags
« Reply #4 on: January 08, 2008, 03:39:27 PM »
smokie,

What version of my script are you using?
version 1.3 had the bug you describe.
If you view the source it says what version at the top
Please download the latest version from today, that should fix it

Download the latest version here:
http://www.642weather.com/weather/scripts/multifunction-image-handler.php?sce=view

# Version: 1.30 07-Jan-2008 - Bug fix for wordwrap true type font text
# Version: 1.40 07-Jan-2008 - Bug fix for text position, not working on vers. 1.30
# Version: 1.50 07-Jan-2008 - Better handling of downloaded file name for local file
# Version: 1.60 08-Jan-2008 - Bug fix for true type fonts, bug fix for local file usage
« Last Edit: December 17, 2008, 04:38:56 AM by MCHALLIS »

Offline MCHALLIS

  • Posts: 2,102
  • Long Beach, WA USA
    • Weather for Long Beach, WA USA
Re: New Script: Text Overlay Web Cam Image from PHP Weather-Display tags
« Reply #5 on: January 08, 2008, 04:07:23 PM »
I am now using this PHP script to generate my web cam image every 5 minutes.

http://www.642weather.com/weather/cam.php

I used to manage the text overlay using WD webcamcapture.exe on my WinXP computer.
That method works pretty good, but the reason I do it now with PHP on my web server is to have better control of the text overlay since I already have weather information on my server using Ken True's PHP Weather-Display tags feature.
I still use WD webcamcapture.exe to send the plain image to my web server every 5 minutes, them my php script overlays text on it.

I even figured out a way to upload my web cam image to weather underground from my server using a PHP script I wrote.
If anybody wants to know exactly how I do it, let me know, I could write a "how to" article on my web site.
« Last Edit: December 17, 2008, 04:39:13 AM by MCHALLIS »

Offline niko

  • syzygy
  • Global Moderator
  • Posts: 21,997
  • Crystal Ball broken! Please post the URL.
  • Northern California, U.S.A.
    • http://www.realweatherstation.com
Re: New Script: Text Overlay Web Cam Image from PHP Weather-Display tags
« Reply #6 on: January 08, 2008, 04:17:37 PM »
It would be really nice if it was possible to archive the overlaid images at intervals  :wink: (Then I could use it  :D )

Offline MCHALLIS

  • Posts: 2,102
  • Long Beach, WA USA
    • Weather for Long Beach, WA USA
Re: New Script: Text Overlay Web Cam Image from PHP Weather-Display tags
« Reply #7 on: January 08, 2008, 04:35:39 PM »
It would be really nice if it was possible to archive the overlaid images at intervals  :wink: (Then I could use it  :D )

It is possible, I have a cronjob running on my server every 5 minutes to generate the text overlay. I use my image handler slightly modified to do that. It would be easy to put a few lines in there as an option to archive the images. The images would be on the web server, is that what you would like? How would you like the images to be timestamped?

I guess I would only do it if someone will actually use it, let me know ...

Offline jmcmurry

  • Jim McMurry
  • Posts: 2,205
  • Mauston, WI, USA
    • Juneau County Weather
Re: New Script: Text Overlay Web Cam Image from PHP Weather-Display tags
« Reply #8 on: January 08, 2008, 05:09:49 PM »
It would be really nice if it was possible to archive the overlaid images at intervals  :wink: (Then I could use it  :D )

I can see how this would be handy for a lot of folks.  I have a similar system running that takes a new photo that's been uploaded, adds an overlay that was previously uploaded by WD, then maintains the last 96 webcam photos.  Then my slideshow script can show a sequence.  I do this with my Wasp2 images too.  I've been thinking about incorporating your new script because of the nice crisp overlay, but haven't gotten to it yet.

- Jim

 Home of NSLog NexStorm Lightning Data Manager

Offline niko

  • syzygy
  • Global Moderator
  • Posts: 21,997
  • Crystal Ball broken! Please post the URL.
  • Northern California, U.S.A.
    • http://www.realweatherstation.com
Re: New Script: Text Overlay Web Cam Image from PHP Weather-Display tags
« Reply #9 on: January 08, 2008, 05:33:23 PM »
It is possible, I have a cronjob running on my server every 5 minutes to generate the text overlay. I use my image handler slightly modified to do that. It would be easy to put a few lines in there as an option to archive the images. The images would be on the web server, is that what you would like? How would you like the images to be timestamped?

I guess I would only do it if someone will actually use it, let me know ...

Currently mine is similar to Jim's. One pic is stored each hour, the filename is imagehh.jpg e.g. image06.jpg so today's "06" replaces yesterday's "06" and the website just displays the current (frequently updated) image and image06 through image20 - which is a very simple html page. I doubt anyone else would want exactly that scheme, and a .php page can surely handle something more complex.

Offline MCHALLIS

  • Posts: 2,102
  • Long Beach, WA USA
    • Weather for Long Beach, WA USA
Re: New Script: Text Overlay Web Cam Image from PHP Weather-Display tags
« Reply #10 on: January 08, 2008, 05:37:48 PM »
niko, I can write a separate cron job PHP script to do that, it is way simple.
Are you able to schedule a cron job on your web server?

« Last Edit: December 17, 2008, 04:39:30 AM by MCHALLIS »

Offline niko

  • syzygy
  • Global Moderator
  • Posts: 21,997
  • Crystal Ball broken! Please post the URL.
  • Northern California, U.S.A.
    • http://www.realweatherstation.com
Re: New Script: Text Overlay Web Cam Image from PHP Weather-Display tags
« Reply #11 on: January 08, 2008, 05:50:14 PM »
niko, I can write a separate cron job PHP script to do that, it is way simple.
Are you able to schedule a cron job on your web server?

Crontab how to
http://www.crontabrocks.org/


No, I can't cron so don't do anything specifically for me, only put your time into this if it's a general interest thing. I think I could work around it with pseudo-chron though...

Offline Fox_Of_The_Wind

  • Anthony
  • Posts: 1,163
  • C:\DOS C:\DOS\RUN RUN\DOS\RUN
  • De Soto Wisconsin USA
    • De Soto Valley Weather
Re: New Script: Text Overlay Web Cam Image from PHP Weather-Display tags
« Reply #12 on: January 08, 2008, 07:52:02 PM »
I am now using this PHP script to generate my web cam image every 5 minutes.

http://www.carmosaic.com/weather/cam.php

I used to manage the text overlay using WD webcamcapture.exe on my WinXP computer.
That method works pretty good, but the reason I do it now with PHP on my web server is to have better control of the text overlay since I already have weather information on my server using Ken True's PHP Weather-Display tags feature.
I still use WD webcamcapture.exe to send the plain image to my web server every 5 minutes, them my php script overlays text on it.

I even figured out a way to upload my web cam image to weather underground from my server using a PHP script I wrote.
If anybody wants to know exactly how I do it, let me know, I could write a "how to" article on my web site.
Well I would like to say good job on the script. If I can get it running anyone can. LOL
Anyway I would like to find out how you made the php script for the weather underground. Thanks!!!!


Offline MCHALLIS

  • Posts: 2,102
  • Long Beach, WA USA
    • Weather for Long Beach, WA USA
Re: New Script: Text Overlay Web Cam Image from PHP Weather-Display tags
« Reply #13 on: January 08, 2008, 08:32:55 PM »
I will make a tutorial on my site for how I did the weather underground PHP upload. The script is very simple, but you have to be able to schedule a cron job on your web server. Give me a day or so to work on it.

Offline smokie

  • Posts: 309
  • WS2300 operational May 2007
  • Newquay, Cornwall UK
    • Newquay cams and weather
Re: New Script: Text Overlay Web Cam Image from PHP Weather-Display tags
« Reply #14 on: January 08, 2008, 08:34:03 PM »
smokie,

What version of my script are you using?
version 1.3 had the bug you describe.
If you view the source it says what version at the top
Please download the latest version from today, that should fix it

Download the latest version here:
http://www.carmosaic.com/weather/scripts/multifunction-image-handler.php?sce=view

# Version: 1.30 07-Jan-2008 - Bug fix for wordwrap true type font text
# Version: 1.40 07-Jan-2008 - Bug fix for text position, not working on vers. 1.30
# Version: 1.50 07-Jan-2008 - Better handling of downloaded file name for local file
# Version: 1.60 08-Jan-2008 - Bug fix for true type fonts, bug fix for local file usage

Yes I am using 1.30, have down loaded the latest, will try 1.60 tomorrow :D

Update, I had a spare 5 mins, yes thats done the trick MCHALLIS :D
« Last Edit: January 08, 2008, 09:19:52 PM by smokie »

Newquay, Cornwall.UK  > WS2300 Operational since May 2007.
From 6/4/08 www.newquayweather.com
** Philip

 

cumulus