从图像中提取 EXIF 信息
我想使用 C# 从图像中读取 EXIF 信息,一切都已就位,我有一个类,可以在其中发送图像,然后可以开始请求 EXIF 标签。
但问题是速度,目前我唯一的选择是使用 Image.FromFile() 将整个图像加载到内存中,在这种情况下这是毫无意义的,因为我只需要一点点信息。
所以我的问题是是否有更好的方法来读取 EXIF,也许只需打开一个文件流并读出该段并自己解析它,但这在我看来就像重新发明轮子。或者也许只是 Image.FromFile() 在这种情况下使用了错误的函数。
请启发我:)
编辑
我最终重新发明了轮子,主要是因为那里的信息非常可怕,而且因为我有几个空闲时间可以消磨。
破译 jpeg/exif/tiff 结构后,我现在可以在几乎零时间内读取和解析 exif 信息。我实际上只需要几个标签,但我可能会随着我的进展扩展这个库。
啊,顺便说一句,这个页面: http://gvsoft.homedns.org/exif/exif-解释.html 非常好,并且免费为您提供很多内容。
I want to read the EXIF information from an image using C#, and everything is actually in place, I have a class where I send in the Image and I can then start requesting EXIF tags.
But the problem is speed, currently my only option is using Image.FromFile() while loads the entire image into memory, which in this case is pretty pointless since I just need a teeny bit of information.
So my question is if there is a better way to read the EXIF, maybe just open a filestream and read out the segment and parse it myself, but that seems to me like reinventing the wheel. Or maybe it's just Image.FromFile() that is the wrong function to use in this case.
Please enlighten me :)
EDIT
I ended up reinventing the wheel, mostly because the information out there was quite horrid, and because I had a few spare hours to kill.
After deciphering the jpeg/exif/tiff structure I can now read and parse the exif information in almost zero time. I really only need a couple of the tags but I may extend this library as I go along.
Ah and btw, this page: http://gvsoft.homedns.org/exif/exif-explanation.html is quite good and gives you alot for free.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我对 exif 不太了解,但是,也许你可以复制 exif 信息并将其写入一个小的临时 jepg 中。之后,您可以按照您的描述阅读小 jpeg。
I don't know much about exif but, perhaps you can copy out the exif information and write it into a tiny temporary jepg. After that you can read the small jpeg as you described.