簡體   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

我試圖使用System.Drawing.Image.GetPropertyItem(0x0112)讀取方向Exif值。

這在Windows 7和Windows 2008 R2上運行正常,但在Windows XP / Windows Server 2003上失敗(獲取“無法找到屬性”錯誤)。

在Windows XP / 2003上,如果我遍歷可用屬性(使用System.Drawing.Image的PropertyItems屬性),我只得到0x5090(PropertyTagLuminanceTable)和0x5091(PropertyTagChrominanceTable)

使用Windows 7 / Windows 2008中的完全相同的圖像,我得到18個屬性,其中一個是0x0112。

我懷疑這可能與Vista和更高版本的Windows有更新版本的GDI +這一事實有關。 有沒有辦法讓這個在Windows XP / 2003上工作,而不必編寫代碼來讀取和寫入Exif數據?

有一個庫中的NuGet稱為ExifReader和伴隨CodeProject上的文章在這里

以下代碼應該用於獲取方向,您可以使用ExifTags的其他枚舉來獲取其他元數據:

object result;

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

var orientation = Convert.ToInt32(result);

我已經使用.Net 4在Windows XP 32-Bit SP3上使用此圖像對此進行了測試,並返回了1的方向,這似乎是正確的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM