I made a web-app to turn almost any bitmap image into a mosaic of minecraft blocks.
It works but can take more than a minute to process with large images. Now I want to display progress while it's processing images to give the user some idea of what's happening.
I have a relatively complicated job with multiple nested loops.
e.g.
for($y = 0;$y < $fullrows; $y++){
for($x = 0;$x < $fullcolumns; $x++){
for($yinside=$y*$texty;$yinside < ($y+1)*$texty;$yinside++){
for($xinside=$x*$textx;$xinside < ($x+1)*$textx;$xinside++){
//Calculate color averages for a picture
}
}
for($ytexture = 0; $ytexture < $texty; $ytexture++){
for($xtexture = 0; $xtexture < $textx; $xtexture++){
//Replace picture blocks with according texture
}
}
}
}
}
//More code and loops for uneven edges
I have already figured how to implement a progress variable and maximum variable. So that when the job finishes p=m. 100*p/m would effectively count progress in percentage during the job.
However I have no idea how to return that progress without polling and with compatibility for IE 8-9.(Not polling and having maximum compatibility)
I read this: http://stratosprovatopoulos.com/web-development/php/ajax-progress-php-script-without-polling/
The demo in the article does not work.. And I'm not sure how to implement those things in a loop.
I understand he is taking advantage of ob_implicit_flush(true); and ob_end_flush();
Which should make the php back-end script output to my client-side script.
In my loops however I open and close texture images with php GD. I also padd and copy images. Aren't those operations going to also be outputted? How to select what I want to echo for progress? Not to echo?
The writer of the mentioned article talks about Comet, should I look into that to understand better?
I need some explanations. Thanks.