Actually I thought the full image files would be prefixed with a "P_" and the thumbnail files would be prefixed with "T_". This would allow them to be identified if sets e.g. P_FILE1 is full and T_FILE1 is thumbnail. However may be this does not make sense.
I get a little lost in altering the "open(OUTFILE...)".
Programmers often use code not written by themselves. It is sometimes a good basis for learning and not making the same mistakes. Merlyn and I would have a great time chatting about the Australian Aborigine Dreamtime which should be included in the Mysterious Places website.