php & gd...outputting image problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
devassocx
Forum Newbie
Posts: 3
Joined: Tue Nov 01, 2005 5:53 pm
Location: Tustin, CA. USA

php & gd...outputting image problem

Post by devassocx »

Hi:

Have an application that is an endless loop structured something like this:

initialize
|
|
start loopa (infinite)
|
|
start loopb (infinite and conditional)
|
|
If event occurs terminate loopb
else redo loopb
|
|
imagepng($image);
imagedestroy($image);
|
|
redo loopa (forever)

The application executes properly. What does not happen however, is that the
graphics image is never displayed. If instead of making loopa an infinite loop
and execution is allowed to terminate and the ?> tag is executed then the graphics
image is displayed.

This same structure, if instead of attempting to output a graphics image, outputs
an echo (or similar) statement then it works as expected.

I have tried many different things to try to coax the graphics image to output
but so far have not found any resolution and I have also failed to find anything
on the web about this.

At this point, I am using apache2 webserver, php 4.3 in local mode with firefox and i.e.
browsers and windows op system.

Since the application depends on continous operation within the loop structures
rather than just a simple single pass I am soliciting assistance from those
more versed in this area.

Thanks in advance,

Bob Downs
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

are you trying to create an animated output? Images won't display in a series unless the image format supports it, which, not many do. A browser will most often continue to attempt to load an image for as long as the stream is open..
devassocx
Forum Newbie
Posts: 3
Joined: Tue Nov 01, 2005 5:53 pm
Location: Tustin, CA. USA

Post by devassocx »

I suppose that this is a type of animation.

The application is to provide an automatically updated strip chart display. the data source is a remote unit that periodically sends a file to the server via ftp.

The idea (which may prove impractical) is to provide the viewer with
an automatically updated view of current as well as historic data.

The load on the server should be very low since the data points come at
least 3 minutes apart and may be much, much longer.

Apparently, the
imagepng($image);
outputs to an internal buffer but
flush();
or
ob_flush();
really don't cause the buffer to be flushed to the browser as one might
hope.

Hope this makes sense.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

It would seem that a self refreshing page and a separate cron process that runs every 3 minutes to check if the file is new (to copy it down to the web server) would be the best option...
devassocx
Forum Newbie
Posts: 3
Joined: Tue Nov 01, 2005 5:53 pm
Location: Tustin, CA. USA

refreshing page

Post by devassocx »

Don't thnk we have access to the server to perform a CRON process...I'll have to check that.

I also have to think about using the html refresh tag.

Thanks for your suggestion.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

there are a few ways around needing cron, such as using user page queries to make ticks in a log file or table that allows you to track how much time has elapsed since the last update thereby allowing your script to decide when to actually look for a new version of the file to copy down to the web server..
Post Reply