Skip to content

Commit

Permalink
Add test for #95
Browse files Browse the repository at this point in the history
  • Loading branch information
oozcitak committed Apr 2, 2022
1 parent f98972b commit 3756040
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions UnitTests/Issues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,35 @@ public void Issue79()
var exception = Record.Exception(() => ImageFile.FromFile(TestHelpers.TestImagePath(".", "issue-79.jpg")));
Assert.Null(exception);
}

[Fact(DisplayName = "Imprecision results from inconsistent use of Float vs Rational in reading & writing GPS lat/long")]
public void Issue95()
{
// set rational lat/long values
var image = ImageFile.FromFile(TestHelpers.TestImagePath(".", "issue-95.jpg"));
image.Properties.Set(new GPSLatitudeLongitude(ExifTag.GPSLatitude, new[]
{
new MathEx.UFraction32(33),
new MathEx.UFraction32(52),
new MathEx.UFraction32(979, 45)
}));
image.Properties.Set(ExifTag.GPSLatitudeRef, GPSLatitudeRef.South);
image.Properties.Set(new GPSLatitudeLongitude(ExifTag.GPSLongitude, new[]
{
new MathEx.UFraction32(151),
new MathEx.UFraction32(12),
new MathEx.UFraction32(23306, 1137)
}));
image.Properties.Set(ExifTag.GPSLongitudeRef, GPSLongitudeRef.East);

// read back
var latitude = image.Properties.Get<GPSLatitudeLongitude>(ExifTag.GPSLatitude);
Assert.Equal(latitude.Seconds.Numerator, (uint)979);
Assert.Equal(latitude.Seconds.Denominator, (uint)45);

var longitude = image.Properties.Get<GPSLatitudeLongitude>(ExifTag.GPSLongitude);
Assert.Equal(longitude.Seconds.Numerator, (uint)23306);
Assert.Equal(longitude.Seconds.Denominator, (uint)1137);
}
}
}
Binary file added UnitTests/TestImages/issue-95.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3756040

Please sign in to comment.