读取 JPEG 元数据(方向)时出现问题 [英] Problem reading JPEG Metadata (Orientation)

查看:22
本文介绍了读取 JPEG 元数据(方向)时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张用 iPhone 拍摄的 JPEG 图像.在我的台式电脑(Windows 照片查看器、Google Chrome 等)上,方向不正确.

I've got a JPEG image which was taken on an iphone. On my desktop PC (Windows Photo Viewer, Google Chrome, etc) the orientation is incorrect.

我正在开发一个 ASP.NET MVC 3 Web 应用程序,我需要在其中上传照片(目前使用 plupload).

I'm working on an ASP.NET MVC 3 web application where i need to upload photos (currently using plupload).

我有一些服务器端代码来处理图像,包括读取 EXIF 数据.

I've got some server-side code to process images, including reading EXIF data.

我尝试读取 EXIF 元数据中的 PropertyTagOrientation 字段(使用 GDI - Image.PropertyItems),但该字段不存在.

I've tried reading the PropertyTagOrientation field in the EXIF meta data (using GDI - Image.PropertyItems), but the field isn't present.

所以它要么是一些特定的 iphone 元数据,要么是一些其他的元数据.

So it's either some specific iphone meta data, or some other meta data.

我使用了另一个工具,例如 Aurigma Photo Uploader,它可以正确读取元数据并旋转图像.它是如何做到这一点的?

I've used another tool like Aurigma Photo Uploader, and it reads the meta data correctly and rotates the image. How does it do this?

有谁知道还有哪些其他 JPEG 元数据可以包含 Aurigma 使用的知道它需要旋转所需的信息?

Does anyone know what other JPEG meta data could contain the information required in order to know that it needs to be rotated, that is used by Aurigma?

这是我用来读取 EXIF 数据的代码:

Here's the code i'm using to read the EXIF data:

var image = Image.FromStream(fileStream);

foreach (var prop in image.PropertyItems)
{
   if (prop.Id == 112 || prop.Id == 5029)
   {
      // do my rotate code - e.g "RotateFlip"
      // Never get's in here - can't find these properties.
   }
}

有什么想法吗?

推荐答案

您似乎忘记了您查找的方向 ID 值是十六进制的.在您使用 112 的地方,您应该使用 0x112.

It appears that you forgotten that the orientation id values you looked up are in hex. Where you use 112, you should have used 0x112.

这篇文章 解释了 Windows 如何调整方向,以及 这个似乎与您正在做的事情非常相关.

This article explains how Windows ballsed-up orientation handing, and this one seems pretty relevant to what you are doing.

这篇关于读取 JPEG 元数据(方向)时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆