从字节找出一个形象的的ContentType [] [英] Finding out the ContentType of a Image from the byte[]
本文介绍了从字节找出一个形象的的ContentType []的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法找出图像的contentType为只从原始字节?
Is there a way to find out what the ContentType of an image is from only the original bytes?
目前我只存储字节[],这是我用它来显示网页上的图像的数据库列。
At the moment I have a database column that stores only the byte[], which I use to display an image on a web page.
MemoryStream ms = new MemoryStream(imageBytes);
Image image = Image.FromStream(ms);
image.Save(context.HttpContext.Response.OutputStream, <--ContentType-->);
我当然可以只保存的ContentType在表中的另一列,但如果有另一种方式例如只是想知道也许净有一种方式来询问数据获取的类型。
I could of course just save the ContentType in another column in the table, but just wondered if there was another way e.g. maybe .Net has a way to interrogate the data to get the type.
推荐答案
看看这个文件签名表。
这篇关于从字节找出一个形象的的ContentType []的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文