chorlton2080
Posts: 124
Joined: Sun Dec 23, 2012 9:44 pm

Incorporate raspistill images into webpage

Mon May 27, 2013 8:08 pm

Hello folks

I've been using the raspistill command to do timelapse: very good it is too. I just wish I could switch the LED off on the most recent package version. That is not the purpose of my post, however.

I've almost reached the end of my patience with trying to get a stream which will show on vanilla browser installations, but then I had an idea: why not take the images taken from raspistill in timelapse mode, choose a static filename, and then refer to the file in a served HTTP script within Apache: then have the script trigger automatic refreshes (as they do in live event coverage) without the user having to click on refesh.

The problem with the above is that I don't know how to! I did a quick search of the Forum without any real success.

If anyone can help I would be very appreciative. I'm sure this would be useful to the community.

LeoWhite
Posts: 131
Joined: Mon Apr 08, 2013 9:20 am
Contact: Website

Re: Incorporate raspistill images into webpage

Mon May 27, 2013 8:51 pm

chorlton2080 wrote: I've almost reached the end of my patience with trying to get a stream which will show on vanilla browser installations, but then I had an idea: why not take the images taken from raspistill in timelapse mode, choose a static filename, and then refer to the file in a served HTTP script within Apache: then have the script trigger automatic refreshes (as they do in live event coverage) without the user having to click on refesh.

The problem with the above is that I don't know how to! I did a quick search of the Forum without any real success.
Have a look at http://en.wikipedia.org/wiki/Meta_refresh

Basically you can put a meta tag in the header of a HTML file to get it to request every X seconds. This is all done on the client side, so should work regardless of what web server you are using on the RPi.

Leo

chorlton2080
Posts: 124
Joined: Sun Dec 23, 2012 9:44 pm

Re: Incorporate raspistill images into webpage

Tue May 28, 2013 7:45 pm

I've made reference to a static file created via raspistill in timelapse mode. However, the static jpg is formed in realtime in a scan line approach (i.e. the file is in various stages of completion). Is there anyway, either through a bash script or the HTML code, of only displaying a completed image on an Apache-served webpage?

LeoWhite
Posts: 131
Joined: Mon Apr 08, 2013 9:20 am
Contact: Website

Re: Incorporate raspistill images into webpage

Tue May 28, 2013 8:03 pm

[quote="chorlton2080"]I've made reference to a static file created via raspistill in timelapse mode. However, the static jpg is formed in realtime in a scan line approach (i.e. the file is in various stages of completion). Is there anyway, either through a bash script or the HTML code, of only displaying a completed image on an Apache-served webpage?[/quote]

Hmm, how large if you jpeg file? It sounds like its taking a long time to load and the web browser is displaying it as it loads.

You can probably so something in Javascript to only display the item when complete. Maybe something like

<img id="image" src="myimage.jpg" style="visibility: hidden" onload="document.getElementById('image').style.visibility = 'visible'" />

which would make the image visible once it has completed loading. (Note: this is completely untested!)


Leo

User avatar
drewibbo
Posts: 41
Joined: Tue Feb 26, 2013 11:54 am
Location: Worthing, UK
Contact: Website

Re: Incorporate raspistill images into webpage

Tue May 28, 2013 8:09 pm

Or, once the jpg has been generated use a mysql database to store the filename and date/time.
When your webpage uses the meta to refresh, you can query the database to search for a newly updated image to display. Voila :D
Andy
Pi Pi Pi...

Return to “Camera board”