is there a way to read only a few bytes out of a BLOB type field in a database (for this question it doesn't matter the DB brand) and determine if the binary content is an image (assume it is one of: JPG, GIF, PNG)? I have a webapp that stores files in the database, and if it is an image, I want to show a thumbnail, otherwise I want to show an icon... but I don't have any MIMETYPE info stored anywhere else for the blob (it's not my design)... and because it is a webapp, the loading of the image needs to occur in a separate call (getImage.ashx) from writing out the <img> tag.. and when I'm writing out the tag I don't want to have to read the entire blob into a library, determine if it is an image, resize it... etc etc ... I'd like to be able to look at the first few bytes and know whether I need to write the tag or not. I don't understand image file structures/formats well enough to know if there is some sort of standard header in the first few bytes that I could read in to tell if it is a JPG, GIF, or PNG.
make sense?
if you want to help me specifically (instead of generally answering whether it can be done) then I'm using .NET C# and SQL 2005
Thanks!