It's possible, but I don't know an algorithm for it off the top of my head.

Of course, if the files are named sequentially (i.e., image0.gif, image1.gif, image2.gif) etc., it would be PAINFULLY easy to write a program to generate the HTML page in Pascal...but the HTML wouldn't be generated server-side, you'd have to generate it and then upload it, and then re-generate the page every time you wanted to update it. PITA factor = high.