Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

real time image show

by Brother Geoff (Initiate)
on Feb 02, 2003 at 19:37 UTC ( #232031=perlquestion: print w/replies, xml ) Need Help??

Brother Geoff has asked for the wisdom of the Perl Monks concerning the following question:

I have a group of images online in a (Linux based) web site. Right now the index page has static images - which I need to replace with constantly changing image(s). Obviously, I know how to upload the pics & display them - but how do you get a perl script to change an image on an already displayed page - without pre-loading all the images first? BTW the images are not thumbnails but on the order of 300widthx200height. So I don't want to have the visitor waiting for all the pics to download to their browser before the first is displayed. If you know of a pre-made Perl script I could use as an example I'ld be most grateful.

Replies are listed 'Best First'.
Re: real time image show
by mattriff (Chaplain) on Feb 02, 2003 at 19:43 UTC
    This would have to be initiated from the client-side, so it's more in the realm of Javascript (or perhaps Flash or a Java applet), I would think.

    Once the page/images are downloaded, the server has nothing else to do until the client asks it for something else.

    Of course, if you were using Javascript to request new images from the server, you could surely use a Perl script on the server-side to send it a random image. At the NMS project you could find one such script, ready to go.

    - Matt Riffle

•Re: real time image show
by merlyn (Sage) on Feb 03, 2003 at 03:37 UTC
Re: real time image show
by zentara (Archbishop) on Feb 03, 2003 at 16:22 UTC
    I'm not entirely sure what you are doing. I would go to various "live webcam" sites and look at their source code. Most of them do it with the html "refresh" command.

    <html><head> <meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"> <meta HTTP-EQUIV="Refresh" CONTENT="100">

    That refreshes the page every 100 seconds. The problem is I'm not sure every browser supports it. Works good on Mozilla. Then just have the perl script change your images as needed, and the browsers will get them every 100 seconds. Maybe you could combine the "refresh" with a java slideshow script. Like the one here Java Slideshow

Re: real time image show
by steves (Curate) on Feb 03, 2003 at 17:29 UTC

    I like Randal's example but I think that's a different problem. He's building a LWP-based browser-like Perl script to go pull just images. That's different than enabling a page in a given browser to refresh its images automagically.

    The way I've done this is with JavaScript and timers. There's an example of that here. Probably lots of others ... I'm at best a mediocre JavaScript hacker so I usually just snarf up someone else's examples as starting points. They're all over the web. Just make sure you try it out on different browsers since JavaScript and other dynamic HTML is notoriously browser specific.

    The page refresh technique mentioned also works but it's not as slick since the whole page gets refreshed. As much as I dislike JavaScript it does make this sort of thing (just updating the image) look pretty nice. A site I worked on does that on mouse scroll-overs with a pretty nice resulting effect.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://232031]
Approved by mattriff
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2021-09-18 00:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?