is there a way to read only a few bytes from a BLOB type field in the database (for this question it does not matter for the DB brand) and determine if the binary content is an image (suppose it is one of: JPG, GIF, PNG)? I have a webapp that stores files in a 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 information stored elsewhere for blob (this is not my design) ... and because it is webapp, the image must be loaded in a separate call (getImage.ashx) from the <img> tag entry .. and when I write the tag, I don’t want to read the entire notepad into the library, determine if it is an image , resize it ... etc. etc. I would like to be able to view the first few bytes and know if I need to write a tag or not.I am not very good at image file structures / formats to find out if there is some standard header in the first bytes that I could read to determine if it is JPG, GIF or PNG.
has the meaning?
if you want to help me (instead of answering at all whether this can be done), I use .NET C # and SQL 2005
Thanks!
source
share