简体   繁体   English

为什么System.Drawing.Image.GetPropertyItem在Windows XP / 2003上的行为与Windows 7相比有所不同

[英]Why does System.Drawing.Image.GetPropertyItem behave differently on Windows XP / 2003 compared to Windows 7

I am trying to read the orientation Exif value using System.Drawing.Image.GetPropertyItem(0x0112). 我试图使用System.Drawing.Image.GetPropertyItem(0x0112)读取方向Exif值。

This works fine on Windows 7 and Windows 2008 R2, but fails on Windows XP / Windows Server 2003 (Get a 'Property Cannot Be Found' error). 这在Windows 7和Windows 2008 R2上运行正常,但在Windows XP / Windows Server 2003上失败(获取“无法找到属性”错误)。

On Windows XP / 2003, if I iterate over the available properties (using the PropertyItems property of System.Drawing.Image), I only get 0x5090 (PropertyTagLuminanceTable) and 0x5091 (PropertyTagChrominanceTable) 在Windows XP / 2003上,如果我遍历可用属性(使用System.Drawing.Image的PropertyItems属性),我只得到0x5090(PropertyTagLuminanceTable)和0x5091(PropertyTagChrominanceTable)

With the exact same image in Windows 7 / Windows 2008, I get 18 properties, one of which is 0x0112. 使用Windows 7 / Windows 2008中的完全相同的图像,我得到18个属性,其中一个是0x0112。

I suspect this may be related to the fact that Vista and later versions of Windows have a newer version of GDI+. 我怀疑这可能与Vista和更高版本的Windows有更新版本的GDI +这一事实有关。 Is there any way to get this to work on Windows XP / 2003 without having to write code to read and write Exif data the hard way? 有没有办法让这个在Windows XP / 2003上工作,而不必编写代码来读取和写入Exif数据?

There is a library on NuGet called ExifReader and an accompanying CodeProject article here . 有一个库中的NuGet称为ExifReader和伴随CodeProject上的文章在这里

The following code should work for getting the orientation, and you can use the other enumerations of ExifTags to get other pieces of metadata: 以下代码应该用于获取方向,您可以使用ExifTags的其他枚举来获取其他元数据:

object result;

var reader = new ExifReader("c:\\temp\\test\\sample.jpg");
reader.GetTagValue(ExifTags.Orientation, out result);

var orientation = Convert.ToInt32(result);

I have tested this with this image on Windows XP 32-Bit SP3 using .Net 4, and it returned an orientation of 1, which appears to be correct. 我已经使用.Net 4在Windows XP 32-Bit SP3上使用此图像对此进行了测试,并返回了1的方向,这似乎是正确的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 MonoMac System.Drawing.Image.GetPropertyItem(0x5100) - MonoMac System.Drawing.Image.GetPropertyItem(0x5100) Windows XP上的System.Drawing.Image.FromStream()“参数无效” - System.Drawing.Image.FromStream() “Parameter is not valid” on Windows XP Windows API EnumWindows和EnumChildWindows函数在Windows XP和7中的行为是否不同 - Do Windows API EnumWindows and EnumChildWindows functions behave differently in Windows XP and 7 为什么文件夹在Windows XP和Windows Server 2003上被锁定? - Why folders are locked on Windows XP and Windows Server 2003? Windows XP / Server 2003 / VS 2010上的CefSharp - CefSharp on Windows XP / Server 2003 / VS 2010 为什么该命令不能在Windows XP上运行? - Why the command does not run on Windows XP? .NET System.Windows Server 2008R2 64bit与所有其他Windows相比的绘图差异(图像在2008R2-64中损坏,但在其他Windows上则没有) - .NET System.Drawing differences in Windows Server 2008R2 64bit compared to all other windows (image is broken in 2008R2-64 but not other Windows) RegisterHotkey 仅适用于 WIndows 7,不适用于 XP、服务器 2003 - RegisterHotkey only working in WIndows 7, not in XP, server 2003 为什么此代码适用于Windows 7,但不适用于Windows XP? - Why does this code work on Windows 7, but doesn't on Windows XP? 为什么SmtpClient在XP / Vista / Win7上的行为会有所不同 - Why would SmtpClient behave differently on XP/Vista/Win7
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM