Browse Source
Merge pull request #582 from SixLabors/exif-fix-array
Fixed bug when marking a value as an array.
af/merge-core
Anton Firsov
8 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
21 additions and
1 deletions
-
src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs
-
tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifProfileTests.cs
-
tests/ImageSharp.Tests/TestImages.cs
-
tests/Images/Input/Jpg/issues/Issue520-InvalidCast.jpg
|
|
|
@ -387,7 +387,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif |
|
|
|
value = this.ConvertValue(dataType, offsetBuffer, numberOfComponents); |
|
|
|
} |
|
|
|
|
|
|
|
exifValue = new ExifValue(tag, dataType, value, isArray: value != null && numberOfComponents > 1); |
|
|
|
exifValue = new ExifValue(tag, dataType, value, isArray: value != null && numberOfComponents != 1); |
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
@ -292,6 +292,22 @@ namespace SixLabors.ImageSharp.Tests |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void TestArrayValueWithUnspecifiedSize() |
|
|
|
{ |
|
|
|
// This images contains array in the exif profile that has zero components.
|
|
|
|
Image<Rgba32> image = TestFile.Create(TestImages.Jpeg.Issues.InvalidCast520).CreateImage(); |
|
|
|
|
|
|
|
ExifProfile profile = image.MetaData.ExifProfile; |
|
|
|
Assert.NotNull(profile); |
|
|
|
|
|
|
|
// Force parsing of the profile.
|
|
|
|
Assert.Equal(24, profile.Values.Count); |
|
|
|
|
|
|
|
byte[] bytes = profile.ToByteArray(); |
|
|
|
Assert.Equal(495, bytes.Length); |
|
|
|
} |
|
|
|
|
|
|
|
private static ExifProfile GetExifProfile() |
|
|
|
{ |
|
|
|
Image<Rgba32> image = TestFile.Create(TestImages.Jpeg.Baseline.Floorplan).CreateImage(); |
|
|
|
|
|
|
|
@ -136,6 +136,7 @@ namespace SixLabors.ImageSharp.Tests |
|
|
|
public const string MultiHuffmanBaseline394 = "Jpg/issues/Issue394-MultiHuffmanBaseline-Speakers.jpg"; |
|
|
|
public const string NoEoiProgressive517 = "Jpg/issues/Issue517-No-EOI-Progressive.jpg"; |
|
|
|
public const string BadRstProgressive518 = "Jpg/issues/Issue518-Bad-RST-Progressive.jpg"; |
|
|
|
public const string InvalidCast520 = "Jpg/issues/Issue520-InvalidCast.jpg"; |
|
|
|
} |
|
|
|
|
|
|
|
public static readonly string[] All = Baseline.All.Concat(Progressive.All).ToArray(); |
|
|
|
|
|
|
|
@ -0,0 +1,3 @@ |
|
|
|
version https://git-lfs.github.com/spec/v1 |
|
|
|
oid sha256:3fe23e56bf22a220efdc75cb98e7c9a7a5e29ca960be5e5dc5ca3a0a33d8cd2c |
|
|
|
size 7751 |