如何判断照片是风景还是肖像? JPEG .NET 元数据方向

发布于 2024-08-28 07:45:20 字数 209 浏览 6 评论 0原文

通过 VB.net/C# 有没有办法读取 JPEG 的任何元数据来判断照片是横向还是纵向拍摄的?

我认为相机首先需要一个加速度计来判断向上的方向......正确吗?假设有这种智能来检测倾斜角度,我将如何从 JPEG 中读取该信息?

我在网上找到了一些示例来使用 vb/.net 读取元数据,但不确定要读取什么才能找到我需要的信息。

感谢任何指点......

Thru VB.net/C# is there any way to read any metadata of off a JPEG to tell if the photo was taken in landscape or portrait?

I would assume a camera would need an accelerometer first of all to even tell what direction is up...correct? Assuming there is that kind of intelligence to detect the angle of tilt, how would I go about reading that info from a JPEG?

I found some samples online to read metadata with vb/.net not sure what to read to find the info i need.

Appreciate any pointers.....

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

巷雨优美回忆 2024-09-04 07:45:21

是的,有一个 EXIF 标签可以存储方向。标签编号 274,值记录在此处。从 JPEG 数据读取标签的示例代码为 可在此处获取

Yes, there's an EXIF tag that can store the orientation. Tag number 274, values are documented here. Sample code to read the tags from the JPEG data is available here.

℉絮湮 2024-09-04 07:45:21

现在许多数码相机内置传感器来检测照片是横向还是纵向模式拍摄的。然后他们将此信息存储在 JPG 的标头中。该数据称为 EXIF。

这是一个关于从 JPG 文件中提取 EXIF 数据的非常好的教程。除了纵向/横向信息之外,您还可以(通常)提取相机的型号/品牌、镜头设置、时间/日期等。

http://www.codeproject.com/KB/graphics/NishExifReader.aspx

A lot of digital cameras now have sensors within them to detect if the picture was taken in landscape or portrait mode. They then store this information in the header of the JPG. This data is known as EXIF.

Here is a pretty good tutorial on extracting the EXIF data from a JPG file. In addition to portrait/landscape info you can also extract (usually) the model/make of camera, lens settings, time/date etc.

http://www.codeproject.com/KB/graphics/NishExifReader.aspx

迟到的我 2024-09-04 07:45:21

简单地将 JPG 图像的宽度与其高度进行比较就足够了,如果宽度 > 则足够。高度,当作风景?

我以前用C#做过这个(虽然我现在不记得实现细节了,但我记得这并不是特别困难,只有几行代码),我工作过的一个网站需要上传的JPG在其中显示一个框架(例如您可能挂在墙上的框架),我们需要知道是否添加框架的横向或纵向版本。

Would it be sufficient to simply compare the width of the JPG image to its height and if width > height, treat as landscape?

I have done this in C# before (although I can't remember the implementation details now but I remember it wasn't particularly difficult, a couple of lines of code only) for a website I worked on which required uploaded JPGs to be displayed within a frame (such as you might hang on your wall) and we needed to know whether to add the landscape or portrait version of the frame.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文