For what it's worth,
merlyn wrote a column in
WebTechniques addressing the issue of thumbnails, at
Thumbnails with PBMTOOLS (Sep 98). Although he doesn't use GD, perhaps the structure of the code will offer you some assistance.
dmm
If you GIVE a man a fish you feed him for a day
But, TEACH him to fish and you feed him for a lifetime