public void WriteTo(ExifProfile profile) { if (!double.IsNaN(Distance) && Distance > 0) { var value = Distance == Double.PositiveInfinity ? new Rational(0xffffffff, 1) : new Rational(Distance); profile.ClearValue(ExifTag.SubjectDistance); profile.SetValue(ExifTag.SubjectDistance, value); } if (Range != DistanceRange.Unknown) { profile.ClearValue(ExifTag.SubjectDistanceRange); profile.SetValue(ExifTag.SubjectDistanceRange, (ushort)Range); } profile.ClearValue(ExifTag.SubjectLocation); profile.ClearValue(ExifTag.SubjectArea); if (Size.HasValue) { var rect = new ushort[] { (ushort)Center.X, (ushort)Center.Y, (ushort)Size.Value.Width, (ushort)Size.Value.Height }; profile.SetValue(ExifTag.SubjectArea, rect); } else if (Diameter.HasValue) { var circle = new ushort[] { (ushort)Center.X, (ushort)Center.Y, (ushort)Diameter.Value }; profile.SetValue(ExifTag.SubjectArea, circle); } else { var origin = new ushort[] { (ushort)Center.X, (ushort)Center.Y }; profile.SetValue(ExifTag.SubjectArea, origin); } if (true) // apparently SubjectLocation is outdated and superseded by SubjectArea, but we write it anyway for backwards compatibility { var origin = new ushort[] { (ushort)Center.X, (ushort)Center.Y }; profile.SetValue(ExifTag.SubjectLocation, origin); } }