As wilku points out, caching these thumbnails would be a good idea. Is there a reason you're storing images in the database? Is there a reason that, if you really want to store them in the DB for whatever reason, you couldn't simply add another column to your table to store the thumbnail data as well?
Grabbing the image data from the table and resizing it on-the-fly without saving it for caching purposes seems to be the most inefficient method of doing what you want. At any rate, if you're still convinced on doing it, you'd simply pull the image data from the table, use [man]imagecreatefromstring/man to create an image resource from it, and then use the resizing functions.