The easiest way is to first do a query to get all of the row keys to process, but no BLOB data. Then iterate over that list (not in SQL) and fetch the BLOB data from the particular row, generate the thumbnail by whatever means, and then write it back to the thumbnail column for the row. It may take some time, but at least you won't have to worry about hitting memory limits or other such frustrating nonsense. It's a good idea to do this when you can be sure that nothing else is using the DB so you can avoid having to worry about transactions, and once you've done it once, update your row insert/update code so that thumbnails are kept up to date during processing rather than as a separate batch step.
As for whether the images should be in the DB, that's a good one. The thumbnails quite possibly should be, but the image data itself could be fairly large (especially with more rows) so perhaps should live as separate files with only the filenames in the DB. You need to balance the ability to normally process the data faster (by not having all that image data in there) against the ability to keep all the data consistent (too easy to get into problems if something is poking around in the image data). I can't really answer that for you as it requires deeper knowledge of the application – it's your job – but I hope this tells you what you should be thinking about when making the decision.