System.Drawing.Image を使用して JPG 画像をロードしています。
type=9、len=4 の EXIF 方向タグ (0x0112) を持つ画像を見つけました
通常、画像をロードすると、Type = 3 (uint16 の配列、len = 2(bytes)) が返されます。手がかりの 1 つは、EXIFTool ( http://www.sno.phy.queensu.ca/~phil/exiftool/ ) で実行したときに、Exif バイト オーダーがリトルエンディアン (Intel、II) であることに気付きました。だから、System.Drawing.Image の EXIF 処理がこのバイト オーダーをサポートしていないか、何らかの方法でリトル エンディアンからバイトを転置する必要があると考えています -> ビッグ エンディアン? ただし、バイト数は適切ではありません。正しく解析される私の他の画像のいくつかは、ビッグ エンディアンです (ただし、まだすべてをチェックしていません)。
PropertyItem.Type のドキュメントでは、9 はリストされていません: https://msdn.microsoft.com/en-us/library/system.drawing.imaging.propertyitem.type(v=vs.110).aspx
関連するコード スニペット:
public static Image RemoveImageOrientation(this Image imageIn)
{
if(imageIn.HasOrientationExifTag())
{
var orientationPropItem = imageIn.GetPropertyItem((int)ImagePropertyItemMetaData.PropertyTagOrientation);
if(orientationPropItem.Type != 3 // array of uint16
|| orientationPropItem.Len != 2) // only one 1 uint (2 bytes)
{
throw new ArgumentException("Unable to parse orientation EXIF tag. Type = " + orientationPropItem.Type + ", len = " + orientationPropItem.Len);
}
var orientationExifTag = BitConverter.ToUInt16(orientationPropItem.Value, 0);