手机拍的照片在手机里看角度一般是正常,上传到电脑后就是旋转90度的了,代码中怎么样读取EXIF信息来判断,C#试了一下Image.PropertyItems,里面可以访问到的参数好少,不象Java等其它的可以那么多直接指定方向旋转信息 … 求指导!
解决方案
20
http://www.codeproject.com/Articles/27242/ExifTagCollection-An-EXIF-metadata-extraction-libr
80
你可以这样读取
private static Dictionary<string, string> ReadExif(Image image) { var exif = new Dictionary<string, string>(); var properties = image.PropertyItems; foreach (var property in properties) { switch (property.Id) { case 0x010E: exif["ImageTitle"] = ASCIIToString(property.Value); break; case 0x010F: exif["Make"] = ASCIIToString(property.Value); break; case 0x0110: exif["Model"] = ASCIIToString(property.Value); break; case 0x0112: exif["Orientation"] = ShortToString(property.Value, 0); break; case 0x011A: exif["XResolution"] = RationalToSingle(property.Value, 0); break; case 0x011B: exif["YResolution"] = RationalToSingle(property.Value, 0); break; case 0x0128: exif["ResolutionUnit"] = ShortToString(property.Value, 0); break; case 0x0131: exif["Software"] = ASCIIToString(property.Value); break; case 0x0132: exif["DateTime"] = ASCIIToString(property.Value); break; //GPS case 0x0002: exif["GPSLatitude"] = string.Format("{0}°{1}′{2}″", RationalToSingle(property.Value, 0), RationalToSingle(property.Value, 8), RationalToSingle(property.Value, 16) ); break; case 0x0004: exif["GPSLongitude"] = string.Format("{0}°{1}′{2}″", RationalToSingle(property.Value, 0), RationalToSingle(property.Value, 8), RationalToSingle(property.Value, 16) ); break; case 0x0006: exif["GPSAltitude"] = RationalToSingle(property.Value, 0); break; } } return exif; }