WXforum.net

Miscellaneous Debris => Tech Corner => Topic started by: uncle_bob on April 17, 2018, 09:36:31 PM

Title: Displaying forecast on photocopier
Post by: uncle_bob on April 17, 2018, 09:36:31 PM
Yes, you read that right haha.
Our photocopier can accept a png image or logo on it's screen along with authentication instructions.
I currently have a static image being displayed but thought it would be cool to update it with a current forecast data from a data provider, such as WU

Since my website uses Ken's awesome WU-forecast script, I was hoping than it mightn't be a too bigger job to adapt this to output a png image, instead of a php page.
Is this a really stupid idea?

Cheers for you thoughts in advance,
UB
Title: Re: Displaying forecast on photocopier
Post by: pfletch101 on April 17, 2018, 11:32:54 PM
How does the image get to the photocopier? If it can be set up to access a 'file' over a network, then you can certainly generate an image in php and point the photocopier to the php script (assuming that it doesn't insist on the file having the right extension for its ostensible type). You can include both graphics and text, but formatting the text is a bit of a pain.
Title: Re: Displaying forecast on photocopier
Post by: uncle_bob on April 17, 2018, 11:45:33 PM
Hi Pfletch,
It simply just needs to be in a certain folder on a windows application server. The photocopier app refreshes it's screen from this folder every minute or so.
Title: Re: Displaying forecast on photocopier
Post by: uncle_bob on April 18, 2018, 12:14:44 AM
Here's a pic with the static image. Looks pretty cool but will be better if I can make the info update automagically :)
(http://cond.power.on.net/files/Screen.JPG)
Title: Re: Displaying forecast on photocopier
Post by: Bushman on April 18, 2018, 05:40:57 AM
Bizarre but neat.  :)
Title: Re: Displaying forecast on photocopier
Post by: pfletch101 on April 18, 2018, 09:32:22 AM
I have attached a zip of the php script that produces the "solar sticker" in the right hand column of my site at https://fletchers-uk.com/ (https://fletchers-uk.com/). The "sticker" is just text on a graphic background and is very simple, but the script should give you an idea of how the process works. To write a file instead of sending back the image as an http(s) response, you just need to add a file path argument to the imagepng() call near the end.
Title: Re: Displaying forecast on photocopier
Post by: vreihen on April 18, 2018, 05:32:44 PM
Where I work, making the copier screen display *anything* would be a bad idea.  Someone would want to take it to the next level and insert ads in place of the forecast.....  #-o
Title: Re: Displaying forecast on photocopier
Post by: uncle_bob on April 18, 2018, 05:54:49 PM
I have attached a zip of the php script that produces the "solar sticker" in the right hand column of my site

Thanks Peter. I'll look into this shortly.
Title: Re: Displaying forecast on photocopier
Post by: uncle_bob on April 18, 2018, 05:55:17 PM
Where I work, making the copier screen display *anything* would be a bad idea.  Someone would want to take it to the next level and insert ads in place of the forecast.....  #-o

Haha, I'd thought of this too :)
Title: Re: Displaying forecast on photocopier
Post by: uncle_bob on April 20, 2018, 09:28:09 PM
ITo write a file instead of sending back the image as an http(s) response, you just need to add a file path argument to the imagepng() call near the end.

Hi Peter, as I'm no coding expert, could you please expand on this?
I've managed to get php to create the formatted table using Kens' WU-forecast and his examples on his website. But getting this table outputted as an image to file is making my head hurt.

If anyone's interested, you can see the table displayed  here (http://cond.power.on.net/WU-data.php)
Title: Re: Displaying forecast on photocopier
Post by: Bushman on April 21, 2018, 02:19:45 AM
I love the disclaimer! LOL "Never base important decisions on information gleaned from this photocopier"  Sentient machines are among us!!
Title: Re: Displaying forecast on photocopier
Post by: uncle_bob on April 21, 2018, 04:03:10 AM
 :grin: Maybe I should put a smiley on the end of that too
Title: Re: Displaying forecast on photocopier
Post by: vreihen on April 21, 2018, 08:44:56 AM
Plenty of different options to make your head hurt even more:

https://stackoverflow.com/questions/757675/website-screenshots (https://stackoverflow.com/questions/757675/website-screenshots)

Personally, I like the Google API thingy if you can find a routine to un-JSON the returned screenshot.....
Title: Re: Displaying forecast on photocopier
Post by: pfletch101 on April 21, 2018, 11:25:18 AM
ITo write a file instead of sending back the image as an http(s) response, you just need to add a file path argument to the imagepng() call near the end.

Hi Peter, as I'm no coding expert, could you please expand on this?

I will send you a PM, since this isn't a PHP coding forum.:-) However, I may not be able to get to this until after the weekend, since there isn't a 'short answer'.
Title: Re: Displaying forecast on photocopier
Post by: Bushman on April 21, 2018, 12:45:02 PM
This isn't an answer, but I was curious.  (YOU never know...)  https://codepedia.info/editor-example/jquery-convert-html-to-image-example/
Title: Re: Displaying forecast on photocopier
Post by: SLOweather on April 21, 2018, 12:50:22 PM
Please feel free to post it here. Lots of other PHP code has been posted over the years, and I always look forward to learning something new.
Title: Re: Displaying forecast on photocopier
Post by: pfletch101 on April 21, 2018, 04:37:16 PM
Rather than attempting to write an original article on writing text and graphics to an image file in PHP, I have extensively commented the script file I originally uploaded, explaining what it is doing, step by step. I have zipped and attached the commented script here. I hope that this helps.