public static void AddAllTest(string sample_file, string tmp_file) { Image.File file = Utils.CreateTmpFile(sample_file, tmp_file) as Image.File; Assert.IsNotNull(file, "file"); // ensure all tags are present file.GetTag(TagTypes.XMP, true); file.GetTag(TagTypes.TiffIFD, true); file.ImageTag.Comment = test_comment; file.ImageTag.Keywords = keywords; file.ImageTag.Rating = 4; file.ImageTag.DateTime = date_time; file.ImageTag.Latitude = 3.0; file.ImageTag.Longitude = 3.0; file.ImageTag.Altitude = 3.0; Assert.AreEqual(test_comment, file.ImageTag.Comment); Assert.AreEqual(keywords, file.ImageTag.Keywords); Assert.AreEqual(4, file.ImageTag.Rating); Assert.AreEqual(date_time, file.ImageTag.DateTime); Assert.AreEqual(3.0, file.ImageTag.Latitude); Assert.AreEqual(3.0, file.ImageTag.Longitude); Assert.AreEqual(3.0, file.ImageTag.Altitude); // Store and reload file file.Save(); file = File.Create(tmp_file) as Image.File; Assert.IsNotNull(file, "tmp file"); Assert.AreEqual(test_comment, file.ImageTag.Comment); Assert.AreEqual(keywords, file.ImageTag.Keywords); Assert.AreEqual(4, file.ImageTag.Rating); Assert.AreEqual(date_time, file.ImageTag.DateTime); Assert.AreEqual(3.0, file.ImageTag.Latitude); Assert.AreEqual(3.0, file.ImageTag.Longitude); Assert.AreEqual(3.0, file.ImageTag.Altitude); var xmp_tag = file.GetTag(TagTypes.XMP, false) as XmpTag; Assert.IsNotNull(xmp_tag, "XMP Tag not read"); Assert.AreEqual(test_comment, xmp_tag.Comment); Assert.AreEqual(keywords, xmp_tag.Keywords); Assert.AreEqual(4, xmp_tag.Rating); var ifd_tag = file.GetTag(TagTypes.TiffIFD, false) as IFDTag; Assert.IsNotNull(ifd_tag, "Tiff Tag not read"); Assert.AreEqual(test_comment, ifd_tag.Comment); Assert.AreEqual(date_time, ifd_tag.DateTime); Assert.AreEqual(3.0, ifd_tag.Latitude); Assert.AreEqual(3.0, ifd_tag.Longitude); Assert.AreEqual(3.0, ifd_tag.Altitude); }
/// <summary> /// Check if the original keywords are found. /// </summary> public override void ValidatePreModification(Image.File file) { if (!tag_present) { Assert.IsNull(file.GetTag(type, false)); } else { Assert.IsNotNull(file.GetTag(type, false)); base.ValidatePreModification(file); } }
public void TestJpegRead() { Assert.IsTrue(_file is Jpeg.File); Assert.AreEqual(CONTAINED_TYPES, _file.TagTypes); Assert.AreEqual(CONTAINED_TYPES, _file.TagTypesOnDisk); Assert.IsNotNull(_file.Properties, "properties"); Assert.AreEqual(7, _file.Properties.PhotoHeight); Assert.AreEqual(10, _file.Properties.PhotoWidth); Assert.AreEqual(90, _file.Properties.PhotoQuality); JpegCommentTag tag = _file.GetTag(TagTypes.JpegComment) as JpegCommentTag; Assert.IsFalse(tag == null); Assert.AreEqual("Test Comment", tag.Value); }
/// <summary> /// Creates the tag if needed. /// </summary> public override void ModifyMetadata(Image.File file) { if (!tag_present) { file.GetTag(type, true); } base.ModifyMetadata(file); }
public void ValidateMetadataInvariants(Image.File file) { Assert.IsNotNull(file); // ---------- Start of IFD tests ---------- var tag = file.GetTag(TagTypes.TiffIFD) as IFDTag; Assert.IsNotNull(tag, "IFD tag not found"); var structure = tag.Structure; // Image.0x010E (ImageDescription/Ascii/32) " " { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.ImageDescription); Assert.IsNotNull(entry, "Entry 0x010E missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual(" ", (entry as StringIFDEntry).Value); } // Image.0x010F (Make/Ascii/5) "SONY" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Make); Assert.IsNotNull(entry, "Entry 0x010F missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("SONY", (entry as StringIFDEntry).Value); } // Image.0x0110 (Model/Ascii/7) "DSC-P8" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Model); Assert.IsNotNull(entry, "Entry 0x0110 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("DSC-P8", (entry as StringIFDEntry).Value); } // Image.0x0112 (Orientation/Short/1) "6" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Orientation); Assert.IsNotNull(entry, "Entry 0x0112 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(6, (entry as ShortIFDEntry).Value); } // Image.0x011A (XResolution/Rational/1) "72/1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.XResolution); Assert.IsNotNull(entry, "Entry 0x011A missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(72, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Image.0x011B (YResolution/Rational/1) "72/1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.YResolution); Assert.IsNotNull(entry, "Entry 0x011B missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(72, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Image.0x0128 (ResolutionUnit/Short/1) "2" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.ResolutionUnit); Assert.IsNotNull(entry, "Entry 0x0128 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Image.0x0131 (Software/Ascii/22) "f-spot version 0.1.11" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Software); Assert.IsNotNull(entry, "Entry 0x0131 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("f-spot version 0.1.11", (entry as StringIFDEntry).Value); } // Image.0x0132 (DateTime/Ascii/20) "2006:06:12 13:30:01" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.DateTime); Assert.IsNotNull(entry, "Entry 0x0132 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("2006:06:12 13:30:01", (entry as StringIFDEntry).Value); } // Image.0x0213 (YCbCrPositioning/Short/1) "2" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.YCbCrPositioning); Assert.IsNotNull(entry, "Entry 0x0213 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Image.0x8769 (ExifTag/SubIFD/1) "250" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.ExifIFD); Assert.IsNotNull(entry, "Entry 0x8769 missing in IFD 0"); Assert.IsNotNull(entry as SubIFDEntry, "Entry is not a sub IFD!"); } var exif = structure.GetEntry(0, (ushort)IFDEntryTag.ExifIFD) as SubIFDEntry; Assert.IsNotNull(exif, "Exif tag not found"); var exif_structure = exif.Structure; // Photo.0x829A (ExposureTime/Rational/1) "10/80" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureTime); Assert.IsNotNull(entry, "Entry 0x829A missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(10, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(80, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x829D (FNumber/Rational/1) "28/10" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FNumber); Assert.IsNotNull(entry, "Entry 0x829D missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(28, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(10, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x8822 (ExposureProgram/Short/1) "2" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureProgram); Assert.IsNotNull(entry, "Entry 0x8822 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Photo.0x8827 (ISOSpeedRatings/Short/1) "320" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ISOSpeedRatings); Assert.IsNotNull(entry, "Entry 0x8827 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(320, (entry as ShortIFDEntry).Value); } // Photo.0x9000 (ExifVersion/Undefined/4) "48 50 50 48" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExifVersion); Assert.IsNotNull(entry, "Entry 0x9000 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 48, 50, 50, 48 }; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0x9003 (DateTimeOriginal/Ascii/20) "2006:06:12 13:28:25" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.DateTimeOriginal); Assert.IsNotNull(entry, "Entry 0x9003 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("2006:06:12 13:28:25", (entry as StringIFDEntry).Value); } // Photo.0x9004 (DateTimeDigitized/Ascii/20) "2006:06:12 13:28:25" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.DateTimeDigitized); Assert.IsNotNull(entry, "Entry 0x9004 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("2006:06:12 13:28:25", (entry as StringIFDEntry).Value); } // Photo.0x9101 (ComponentsConfiguration/Undefined/4) "1 2 3 0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ComponentsConfiguration); Assert.IsNotNull(entry, "Entry 0x9101 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 1, 2, 3, 0 }; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0x9102 (CompressedBitsPerPixel/Rational/1) "4/1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.CompressedBitsPerPixel); Assert.IsNotNull(entry, "Entry 0x9102 missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(4, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x9204 (ExposureBiasValue/SRational/1) "0/10" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureBiasValue); Assert.IsNotNull(entry, "Entry 0x9204 missing in IFD 0"); Assert.IsNotNull(entry as SRationalIFDEntry, "Entry is not a srational!"); Assert.AreEqual(0, (entry as SRationalIFDEntry).Value.Numerator); Assert.AreEqual(10, (entry as SRationalIFDEntry).Value.Denominator); } // Photo.0x9205 (MaxApertureValue/Rational/1) "48/16" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.MaxApertureValue); Assert.IsNotNull(entry, "Entry 0x9205 missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(48, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(16, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x9207 (MeteringMode/Short/1) "5" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.MeteringMode); Assert.IsNotNull(entry, "Entry 0x9207 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(5, (entry as ShortIFDEntry).Value); } // Photo.0x9208 (LightSource/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.LightSource); Assert.IsNotNull(entry, "Entry 0x9208 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0x9209 (Flash/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.Flash); Assert.IsNotNull(entry, "Entry 0x9209 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0x920A (FocalLength/Rational/1) "60/10" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FocalLength); Assert.IsNotNull(entry, "Entry 0x920A missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(60, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(10, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x927C (MakerNote/MakerNote/1504) "(Value ommitted)" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.MakerNote); Assert.IsNotNull(entry, "Entry 0x927C missing in IFD 0"); Assert.IsNotNull(entry as MakernoteIFDEntry, "Entry is not a makernote IFD!"); } var makernote = exif_structure.GetEntry(0, (ushort)ExifEntryTag.MakerNote) as MakernoteIFDEntry; Assert.IsNotNull(makernote, "MakerNote tag not found"); var makernote_structure = makernote.Structure; // Sony.0x9001 (0x9001/Undefined/148) "0 55 0 0 0 8 0 136 147 53 0 194 66 169 0 125 23 0 0 0 0 203 0 0 0 0 0 0 0 203 0 1 91 213 255 0 0 216 0 0 105 4 149 0 255 106 224 125 64 220 14 136 255 74 255 240 0 0 0 74 136 0 136 125 5 74 136 0 136 125 5 74 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 140" { // TODO: Unknown IFD tag: Sony / 0x9001 var entry = makernote_structure.GetEntry(0, (ushort)0x9001); Assert.IsNotNull(entry, "Entry 0x9001 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 0, 55, 0, 0, 0, 8, 0, 136, 147, 53, 0, 194, 66, 169, 0, 125, 23, 0, 0, 0, 0, 203, 0, 0, 0, 0, 0, 0, 0, 203, 0, 1, 91, 213, 255, 0, 0, 216, 0, 0, 105, 4, 149, 0, 255, 106, 224, 125, 64, 220, 14, 136, 255, 74, 255, 240, 0, 0, 0, 74, 136, 0, 136, 125, 5, 74, 136, 0, 136, 125, 5, 74, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 140 }; Assert.AreEqual(bytes, parsed_bytes); } // Sony.0x9002 (0x9002/Undefined/200) "2 239 0 140 2 239 0 0 0 125 0 0 0 0 0 0 0 0 0 0 0 0 205 0 0 0 0 0 112 0 112 42 14 172 205 0 0 0 0 0 0 0 0 0 112 143 138 95 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 27 11 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 182 8 92 0 125 0 182 0 0 0 4 0 63 63 0 112 170 112 170 112 42 64 0 0 0 220 220 115 70 0 79" { // TODO: Unknown IFD tag: Sony / 0x9002 var entry = makernote_structure.GetEntry(0, (ushort)0x9002); Assert.IsNotNull(entry, "Entry 0x9002 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 2, 239, 0, 140, 2, 239, 0, 0, 0, 125, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 205, 0, 0, 0, 0, 0, 112, 0, 112, 42, 14, 172, 205, 0, 0, 0, 0, 0, 0, 0, 0, 0, 112, 143, 138, 95, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 182, 8, 92, 0, 125, 0, 182, 0, 0, 0, 4, 0, 63, 63, 0, 112, 170, 112, 170, 112, 42, 64, 0, 0, 0, 220, 220, 115, 70, 0, 79 }; Assert.AreEqual(bytes, parsed_bytes); } // Sony.0x9003 (0x9003/Undefined/200) "0 239 0 110 0 91 0 50 0 43 0 219 0 115 57 131 26 208 135 188 26 208 26 177 234 34 125 13 163 57 219 57 219 57 219 7 148 194 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 0 1 217 0 91 0 147 216 8 48 136 0 0 48 136 1 238 1 139 1 1 0 255 231 253 231 168 123 219 60 123 0 0 75 234 187 7 207 27 146 131 2 11 92 82 121 97 7 238 7 133 16 171 1 42 58 253 185 174 154 252 5 92 140 45 40 130 108 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 32 8 27 0 1 220 220 188 95 16 0 0 8 231 8 182" { // TODO: Unknown IFD tag: Sony / 0x9003 var entry = makernote_structure.GetEntry(0, (ushort)0x9003); Assert.IsNotNull(entry, "Entry 0x9003 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 0, 239, 0, 110, 0, 91, 0, 50, 0, 43, 0, 219, 0, 115, 57, 131, 26, 208, 135, 188, 26, 208, 26, 177, 234, 34, 125, 13, 163, 57, 219, 57, 219, 57, 219, 7, 148, 194, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 1, 217, 0, 91, 0, 147, 216, 8, 48, 136, 0, 0, 48, 136, 1, 238, 1, 139, 1, 1, 0, 255, 231, 253, 231, 168, 123, 219, 60, 123, 0, 0, 75, 234, 187, 7, 207, 27, 146, 131, 2, 11, 92, 82, 121, 97, 7, 238, 7, 133, 16, 171, 1, 42, 58, 253, 185, 174, 154, 252, 5, 92, 140, 45, 40, 130, 108, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 32, 8, 27, 0, 1, 220, 220, 188, 95, 16, 0, 0, 8, 231, 8, 182 }; Assert.AreEqual(bytes, parsed_bytes); } // Sony.0x9004 (0x9004/Undefined/26) "8 234 8 138 0 227 0 150 0 227 0 227 0 0 0 0 0 1 0 0 1 1 0 0 0 0" { // TODO: Unknown IFD tag: Sony / 0x9004 var entry = makernote_structure.GetEntry(0, (ushort)0x9004); Assert.IsNotNull(entry, "Entry 0x9004 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 8, 234, 8, 138, 0, 227, 0, 150, 0, 227, 0, 227, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0 }; Assert.AreEqual(bytes, parsed_bytes); } // Sony.0x9005 (0x9005/Undefined/120) "0 14 0 0 0 0 0 58 0 0 0 0 0 0 0 216 0 0 0 0 0 27 0 0 0 1 0 1 0 1 0 1 0 0 0 1 0 1 0 8 0 0 0 0 14 4 234 234 136 108 149 129 86 125 8 0 0 0 0 0 0 187 182 0 0 0 0 255 255 0 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 64 0 64 0 64 0 0 0 0 0 0" { // TODO: Unknown IFD tag: Sony / 0x9005 var entry = makernote_structure.GetEntry(0, (ushort)0x9005); Assert.IsNotNull(entry, "Entry 0x9005 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 0, 14, 0, 0, 0, 0, 0, 58, 0, 0, 0, 0, 0, 0, 0, 216, 0, 0, 0, 0, 0, 27, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 8, 0, 0, 0, 0, 14, 4, 234, 234, 136, 108, 149, 129, 86, 125, 8, 0, 0, 0, 0, 0, 0, 187, 182, 0, 0, 0, 0, 255, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 64, 0, 64, 0, 0, 0, 0, 0, 0 }; Assert.AreEqual(bytes, parsed_bytes); } // Sony.0x9006 (0x9006/Undefined/252) "236 109 0 0 190 132 0 0 190 70 0 0 190 216 0 0 182 150 0 0 138 148 0 0 32 216 0 0 48 131 0 0 105 103 0 0 105 139 0 0 105 102 0 0 112 88 0 0 112 84 0 0 32 20 0 0 136 243 0 0 105 85 0 0 215 44 0 0 129 198 0 0 136 157 0 0 136 144 0 0 129 124 0 0 182 35 0 0 138 119 0 0 136 3 0 0 136 120 0 0 182 175 0 0 105 81 0 0 48 76 0 0 138 216 0 0 5 106 0 0 182 63 0 0 105 210 0 0 138 128 0 0 182 45 0 0 48 234 0 0 5 236 0 0 205 117 0 0 182 9 0 0 136 149 0 0 112 189 0 0 112 234 0 0 182 54 0 0 205 172 0 0 4 117 0 0 234 174 0 0 138 125 0 0 205 15 0 0 234 99 0 0 234 181 194 127 246 246 246 127 194 194 127 246 246 246 127 194 127 246 238 56 238 246 127 246 238 208 131 208 238 246 246 56 131 74 131 56 246 246 238 208 131 208 238 246 127 246 238 56 238 246 127 0 0 0 0 0 234 93 234 189" { // TODO: Unknown IFD tag: Sony / 0x9006 var entry = makernote_structure.GetEntry(0, (ushort)0x9006); Assert.IsNotNull(entry, "Entry 0x9006 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 236, 109, 0, 0, 190, 132, 0, 0, 190, 70, 0, 0, 190, 216, 0, 0, 182, 150, 0, 0, 138, 148, 0, 0, 32, 216, 0, 0, 48, 131, 0, 0, 105, 103, 0, 0, 105, 139, 0, 0, 105, 102, 0, 0, 112, 88, 0, 0, 112, 84, 0, 0, 32, 20, 0, 0, 136, 243, 0, 0, 105, 85, 0, 0, 215, 44, 0, 0, 129, 198, 0, 0, 136, 157, 0, 0, 136, 144, 0, 0, 129, 124, 0, 0, 182, 35, 0, 0, 138, 119, 0, 0, 136, 3, 0, 0, 136, 120, 0, 0, 182, 175, 0, 0, 105, 81, 0, 0, 48, 76, 0, 0, 138, 216, 0, 0, 5, 106, 0, 0, 182, 63, 0, 0, 105, 210, 0, 0, 138, 128, 0, 0, 182, 45, 0, 0, 48, 234, 0, 0, 5, 236, 0, 0, 205, 117, 0, 0, 182, 9, 0, 0, 136, 149, 0, 0, 112, 189, 0, 0, 112, 234, 0, 0, 182, 54, 0, 0, 205, 172, 0, 0, 4, 117, 0, 0, 234, 174, 0, 0, 138, 125, 0, 0, 205, 15, 0, 0, 234, 99, 0, 0, 234, 181, 194, 127, 246, 246, 246, 127, 194, 194, 127, 246, 246, 246, 127, 194, 127, 246, 238, 56, 238, 246, 127, 246, 238, 208, 131, 208, 238, 246, 246, 56, 131, 74, 131, 56, 246, 246, 238, 208, 131, 208, 238, 246, 127, 246, 238, 56, 238, 246, 127, 0, 0, 0, 0, 0, 234, 93, 234, 189 }; Assert.AreEqual(bytes, parsed_bytes); } // Sony.0x9007 (0x9007/Undefined/200) "205 208 5 136 5 253 112 229 105 211 136 29 48 131 190 134 0 163 112 161 182 88 105 28 136 132 48 116 215 21 187 90 12 90 236 140 108 109 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 64 183 64 187 27 253 64 234 64 105 64 90 64 53 125 12 125 29 216 13 0 163 64 53 64 144 64 254 125 138 125 196 125 58 216 36 94 36 14 249 4 114 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 199 231 0 14 13 14 67 231 26 231 84 231 74 4 26 4 58 86 194 0 163 138 95 138 233 138 107 138 201 112 234 112 172 112 65 112 204 112 133 112 143 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0" { // TODO: Unknown IFD tag: Sony / 0x9007 var entry = makernote_structure.GetEntry(0, (ushort)0x9007); Assert.IsNotNull(entry, "Entry 0x9007 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 205, 208, 5, 136, 5, 253, 112, 229, 105, 211, 136, 29, 48, 131, 190, 134, 0, 163, 112, 161, 182, 88, 105, 28, 136, 132, 48, 116, 215, 21, 187, 90, 12, 90, 236, 140, 108, 109, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 183, 64, 187, 27, 253, 64, 234, 64, 105, 64, 90, 64, 53, 125, 12, 125, 29, 216, 13, 0, 163, 64, 53, 64, 144, 64, 254, 125, 138, 125, 196, 125, 58, 216, 36, 94, 36, 14, 249, 4, 114, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 199, 231, 0, 14, 13, 14, 67, 231, 26, 231, 84, 231, 74, 4, 26, 4, 58, 86, 194, 0, 163, 138, 95, 138, 233, 138, 107, 138, 201, 112, 234, 112, 172, 112, 65, 112, 204, 112, 133, 112, 143, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; Assert.AreEqual(bytes, parsed_bytes); } // Sony.0x9008 (0x9008/Undefined/200) "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 1 0 2 0" { // TODO: Unknown IFD tag: Sony / 0x9008 var entry = makernote_structure.GetEntry(0, (ushort)0x9008); Assert.IsNotNull(entry, "Entry 0x9008 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 1, 0, 2, 0 }; Assert.AreEqual(bytes, parsed_bytes); } // ---------- End of IFD tests ---------- }
/// <summary> /// Validates if changes survived a write. /// </summary> public void ValidatePostModification(Image.File file) { Assert.IsNotNull(file.GetTag(TagTypes.XMP, false)); Assert.AreEqual(test_keywords, GetTag(file).Keywords); }
public void ValidateMetadataInvariants(Image.File file) { Assert.IsNotNull(file); // ---------- Start of IFD tests ---------- var tag = file.GetTag(TagTypes.TiffIFD) as IFDTag; Assert.IsNotNull(tag, "IFD tag not found"); var structure = tag.Structure; // Image.0x010F (Make/Ascii/2) "o2" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Make); Assert.IsNotNull(entry, "Entry 0x010F missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("o2", (entry as StringIFDEntry).Value); } // Image.0x0110 (Model/Ascii/11) "Xda_diamond" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Model); Assert.IsNotNull(entry, "Entry 0x0110 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("Xda_diamond", (entry as StringIFDEntry).Value); } // Image.0x0112 (Orientation/Short/1) "1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Orientation); Assert.IsNotNull(entry, "Entry 0x0112 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(1, (entry as ShortIFDEntry).Value); } // Image.0x011A (XResolution/Rational/1) "72/1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.XResolution); Assert.IsNotNull(entry, "Entry 0x011A missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(72, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Image.0x011B (YResolution/Rational/1) "72/1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.YResolution); Assert.IsNotNull(entry, "Entry 0x011B missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(72, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Image.0x0128 (ResolutionUnit/Short/1) "2" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.ResolutionUnit); Assert.IsNotNull(entry, "Entry 0x0128 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Image.0x0131 (Software/Ascii/14) "6_00_30998_01" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Software); Assert.IsNotNull(entry, "Entry 0x0131 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("6_00_30998_01", (entry as StringIFDEntry).Value); } // Image.0x0213 (YCbCrPositioning/Short/1) "1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.YCbCrPositioning); Assert.IsNotNull(entry, "Entry 0x0213 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(1, (entry as ShortIFDEntry).Value); } // Image.0x8769 (ExifTag/SubIFD/1) "200" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.ExifIFD); Assert.IsNotNull(entry, "Entry 0x8769 missing in IFD 0"); Assert.IsNotNull(entry as SubIFDEntry, "Entry is not a sub IFD!"); } var exif = structure.GetEntry(0, (ushort)IFDEntryTag.ExifIFD) as SubIFDEntry; Assert.IsNotNull(exif, "Exif tag not found"); var exif_structure = exif.Structure; // Photo.0x8827 (ISOSpeedRatings/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ISOSpeedRatings); Assert.IsNotNull(entry, "Entry 0x8827 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0x9204 (ExposureBiasValue/SRational/1) "0/1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureBiasValue); Assert.IsNotNull(entry, "Entry 0x9204 missing in IFD 0"); Assert.IsNotNull(entry as SRationalIFDEntry, "Entry is not a srational!"); Assert.AreEqual(0, (entry as SRationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as SRationalIFDEntry).Value.Denominator); } // Photo.0x0132 (0x0132/Ascii/20) "2008:08:22 15:55:31" { var entry = exif_structure.GetEntry(0, (ushort)IFDEntryTag.DateTime); Assert.IsNotNull(entry, "Entry 0x0132 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("2008:08:22 15:55:31", (entry as StringIFDEntry).Value); } // Photo.0x9000 (ExifVersion/Undefined/4) "48 50 50 48" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExifVersion); Assert.IsNotNull(entry, "Entry 0x9000 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 48, 50, 50, 48 }; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0x9003 (DateTimeOriginal/Ascii/20) "2008:08:22 15:55:31" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.DateTimeOriginal); Assert.IsNotNull(entry, "Entry 0x9003 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("2008:08:22 15:55:31", (entry as StringIFDEntry).Value); } // Photo.0x9004 (DateTimeDigitized/Ascii/20) "2008:08:22 15:55:31" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.DateTimeDigitized); Assert.IsNotNull(entry, "Entry 0x9004 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("2008:08:22 15:55:31", (entry as StringIFDEntry).Value); } // Photo.0x9101 (ComponentsConfiguration/Undefined/4) "1 2 3 0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ComponentsConfiguration); Assert.IsNotNull(entry, "Entry 0x9101 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 1, 2, 3, 0 }; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0x9209 (Flash/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.Flash); Assert.IsNotNull(entry, "Entry 0x9209 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0xA000 (FlashpixVersion/Undefined/4) "48 49 48 48" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FlashpixVersion); Assert.IsNotNull(entry, "Entry 0xA000 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 48, 49, 48, 48 }; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0xA001 (ColorSpace/Short/1) "1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ColorSpace); Assert.IsNotNull(entry, "Entry 0xA001 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(1, (entry as ShortIFDEntry).Value); } // Photo.0xA002 (PixelXDimension/Long/1) "2048" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.PixelXDimension); Assert.IsNotNull(entry, "Entry 0xA002 missing in IFD 0"); Assert.IsNotNull(entry as LongIFDEntry, "Entry is not a long!"); Assert.AreEqual(2048, (entry as LongIFDEntry).Value); } // Photo.0xA003 (PixelYDimension/Long/1) "1536" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.PixelYDimension); Assert.IsNotNull(entry, "Entry 0xA003 missing in IFD 0"); Assert.IsNotNull(entry as LongIFDEntry, "Entry is not a long!"); Assert.AreEqual(1536, (entry as LongIFDEntry).Value); } // Photo.0xA005 (InteroperabilityTag/SubIFD/1) "530" { var entry = exif_structure.GetEntry(0, (ushort)IFDEntryTag.InteroperabilityIFD); Assert.IsNotNull(entry, "Entry 0xA005 missing in IFD 0"); Assert.IsNotNull(entry as SubIFDEntry, "Entry is not a sub IFD!"); } var iop = exif_structure.GetEntry(0, (ushort)IFDEntryTag.InteroperabilityIFD) as SubIFDEntry; Assert.IsNotNull(iop, "Iop tag not found"); var iop_structure = iop.Structure; // Iop.0x0001 (InteroperabilityIndex/Ascii/4) "R98" { var entry = iop_structure.GetEntry(0, (ushort)IOPEntryTag.InteroperabilityIndex); Assert.IsNotNull(entry, "Entry 0x0001 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("R98", (entry as StringIFDEntry).Value); } // Iop.0x0002 (InteroperabilityVersion/Undefined/4) "48 49 48 48" { var entry = iop_structure.GetEntry(0, (ushort)IOPEntryTag.InteroperabilityVersion); Assert.IsNotNull(entry, "Entry 0x0002 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 48, 49, 48, 48 }; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0xA300 (FileSource/Undefined/1) "3" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FileSource); Assert.IsNotNull(entry, "Entry 0xA300 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 3 }; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0xA301 (SceneType/Undefined/1) "1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.SceneType); Assert.IsNotNull(entry, "Entry 0xA301 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 1 }; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0xA403 (WhiteBalance/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.WhiteBalance); Assert.IsNotNull(entry, "Entry 0xA403 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Thumbnail.0x0103 (Compression/Short/1) "6" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.Compression); Assert.IsNotNull(entry, "Entry 0x0103 missing in IFD 1"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(6, (entry as ShortIFDEntry).Value); } // Thumbnail.0x011B (YResolution/Rational/1) "72/1" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.YResolution); Assert.IsNotNull(entry, "Entry 0x011B missing in IFD 1"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(72, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Thumbnail.0x0128 (ResolutionUnit/Short/1) "2" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.ResolutionUnit); Assert.IsNotNull(entry, "Entry 0x0128 missing in IFD 1"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Thumbnail.0x0201 (JPEGInterchangeFormat/ThumbnailDataIFD/1) "670" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.JPEGInterchangeFormat); Assert.IsNotNull(entry, "Entry 0x0201 missing in IFD 1"); Assert.IsNotNull(entry as ThumbnailDataIFDEntry, "Entry is not a thumbnail IFD!"); } // Thumbnail.0x0202 (JPEGInterchangeFormatLength/Long/1) "16354" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.JPEGInterchangeFormatLength); Assert.IsNotNull(entry, "Entry 0x0202 missing in IFD 1"); Assert.IsNotNull(entry as LongIFDEntry, "Entry is not a long!"); Assert.AreEqual(16354, (entry as LongIFDEntry).Value); } // ---------- End of IFD tests ---------- }
public override Image.ImageTag GetTag(Image.File file) { return(file.GetTag(type, false) as Image.ImageTag); }
public void ValidateMetadataInvariants(Image.File file) { Assert.IsNotNull(file); // ---------- Start of IFD tests ---------- var tag = file.GetTag(TagTypes.TiffIFD) as IFDTag; Assert.IsNotNull(tag, "IFD tag not found"); var structure = tag.Structure; // Image.0x010F (Make/Ascii/6) "Canon" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Make); Assert.IsNotNull(entry, "Entry 0x010F missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("Canon", (entry as StringIFDEntry).Value); } // Image.0x0110 (Model/Ascii/21) "Canon EOS 5D Mark II" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Model); Assert.IsNotNull(entry, "Entry 0x0110 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("Canon EOS 5D Mark II", (entry as StringIFDEntry).Value); } // Image.0x0112 (Orientation/Short/1) "1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Orientation); Assert.IsNotNull(entry, "Entry 0x0112 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(1, (entry as ShortIFDEntry).Value); } // Image.0x011A (XResolution/Rational/1) "72/1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.XResolution); Assert.IsNotNull(entry, "Entry 0x011A missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(72, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Image.0x011B (YResolution/Rational/1) "72/1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.YResolution); Assert.IsNotNull(entry, "Entry 0x011B missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(72, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Image.0x0128 (ResolutionUnit/Short/1) "2" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.ResolutionUnit); Assert.IsNotNull(entry, "Entry 0x0128 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Image.0x0131 (Software/Ascii/23) "f-spot version 0.6.1.5" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Software); Assert.IsNotNull(entry, "Entry 0x0131 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("f-spot version 0.6.1.5", (entry as StringIFDEntry).Value); } // Image.0x0132 (DateTime/Ascii/20) "2010:09:29 20:49:37" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.DateTime); Assert.IsNotNull(entry, "Entry 0x0132 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("2010:09:29 20:49:37", (entry as StringIFDEntry).Value); } // Image.0x013B (Artist/Ascii/1) "" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Artist); Assert.IsNotNull(entry, "Entry 0x013B missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("", (entry as StringIFDEntry).Value.Trim()); } // Image.0x0213 (YCbCrPositioning/Short/1) "2" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.YCbCrPositioning); Assert.IsNotNull(entry, "Entry 0x0213 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Image.0x8298 (Copyright/Ascii/1) "" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Copyright); Assert.IsNotNull(entry, "Entry 0x8298 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("", (entry as StringIFDEntry).Value.Trim()); } // Image.0x8769 (ExifTag/SubIFD/1) "258" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.ExifIFD); Assert.IsNotNull(entry, "Entry 0x8769 missing in IFD 0"); Assert.IsNotNull(entry as SubIFDEntry, "Entry is not a sub IFD!"); } var exif = structure.GetEntry(0, (ushort)IFDEntryTag.ExifIFD) as SubIFDEntry; Assert.IsNotNull(exif, "Exif tag not found"); var exif_structure = exif.Structure; // Photo.0x829A (ExposureTime/Rational/1) "1/125" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureTime); Assert.IsNotNull(entry, "Entry 0x829A missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(125, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x829D (FNumber/Rational/1) "4/1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FNumber); Assert.IsNotNull(entry, "Entry 0x829D missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(4, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x8822 (ExposureProgram/Short/1) "1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureProgram); Assert.IsNotNull(entry, "Entry 0x8822 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(1, (entry as ShortIFDEntry).Value); } // Photo.0x8827 (ISOSpeedRatings/Short/1) "1600" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ISOSpeedRatings); Assert.IsNotNull(entry, "Entry 0x8827 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(1600, (entry as ShortIFDEntry).Value); } // Photo.0x9000 (ExifVersion/Undefined/4) "48 50 50 49 " { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExifVersion); Assert.IsNotNull(entry, "Entry 0x9000 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 48, 50, 50, 49 }; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0x9003 (DateTimeOriginal/Ascii/20) "2009:05:16 20:37:35" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.DateTimeOriginal); Assert.IsNotNull(entry, "Entry 0x9003 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("2009:05:16 20:37:35", (entry as StringIFDEntry).Value); } // Photo.0x9004 (DateTimeDigitized/Ascii/20) "2009:05:16 18:58:35" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.DateTimeDigitized); Assert.IsNotNull(entry, "Entry 0x9004 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("2009:05:16 18:58:35", (entry as StringIFDEntry).Value); } // Photo.0x9101 (ComponentsConfiguration/Undefined/4) "1 2 3 0 " { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ComponentsConfiguration); Assert.IsNotNull(entry, "Entry 0x9101 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 1, 2, 3, 0 }; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0x9201 (ShutterSpeedValue/SRational/1) "458752/65536" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ShutterSpeedValue); Assert.IsNotNull(entry, "Entry 0x9201 missing in IFD 0"); Assert.IsNotNull(entry as SRationalIFDEntry, "Entry is not a srational!"); Assert.AreEqual(458752, (entry as SRationalIFDEntry).Value.Numerator); Assert.AreEqual(65536, (entry as SRationalIFDEntry).Value.Denominator); } // Photo.0x9202 (ApertureValue/Rational/1) "262144/65536" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ApertureValue); Assert.IsNotNull(entry, "Entry 0x9202 missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(262144, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(65536, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x9204 (ExposureBiasValue/SRational/1) "0/1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureBiasValue); Assert.IsNotNull(entry, "Entry 0x9204 missing in IFD 0"); Assert.IsNotNull(entry as SRationalIFDEntry, "Entry is not a srational!"); Assert.AreEqual(0, (entry as SRationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as SRationalIFDEntry).Value.Denominator); } // Photo.0x9207 (MeteringMode/Short/1) "2" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.MeteringMode); Assert.IsNotNull(entry, "Entry 0x9207 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Photo.0x9209 (Flash/Short/1) "9" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.Flash); Assert.IsNotNull(entry, "Entry 0x9209 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(9, (entry as ShortIFDEntry).Value); } // Photo.0x920A (FocalLength/Rational/1) "95/1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FocalLength); Assert.IsNotNull(entry, "Entry 0x920A missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(95, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x9286 (UserComment/UserComment/8) "charset="Ascii" " { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.UserComment); Assert.IsNotNull(entry, "Entry 0x9286 missing in IFD 0"); Assert.IsNotNull(entry as UserCommentIFDEntry, "Entry is not a user comment!"); Assert.AreEqual("", (entry as UserCommentIFDEntry).Value.Trim()); } // Photo.0x9290 (SubSecTime/Ascii/3) "09" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.SubsecTime); Assert.IsNotNull(entry, "Entry 0x9290 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("09", (entry as StringIFDEntry).Value); } // Photo.0x9291 (SubSecTimeOriginal/Ascii/3) "09" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.SubsecTimeOriginal); Assert.IsNotNull(entry, "Entry 0x9291 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("09", (entry as StringIFDEntry).Value); } // Photo.0x9292 (SubSecTimeDigitized/Ascii/3) "09" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.SubsecTimeDigitized); Assert.IsNotNull(entry, "Entry 0x9292 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("09", (entry as StringIFDEntry).Value); } // Photo.0xA000 (FlashpixVersion/Undefined/4) "48 49 48 48 " { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FlashpixVersion); Assert.IsNotNull(entry, "Entry 0xA000 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 48, 49, 48, 48 }; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0xA001 (ColorSpace/Short/1) "1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ColorSpace); Assert.IsNotNull(entry, "Entry 0xA001 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(1, (entry as ShortIFDEntry).Value); } // Photo.0xA002 (PixelXDimension/Long/1) "3253" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.PixelXDimension); Assert.IsNotNull(entry, "Entry 0xA002 missing in IFD 0"); Assert.IsNotNull(entry as LongIFDEntry, "Entry is not a long!"); Assert.AreEqual(3253, (entry as LongIFDEntry).Value); } // Photo.0xA003 (PixelYDimension/Long/1) "4880" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.PixelYDimension); Assert.IsNotNull(entry, "Entry 0xA003 missing in IFD 0"); Assert.IsNotNull(entry as LongIFDEntry, "Entry is not a long!"); Assert.AreEqual(4880, (entry as LongIFDEntry).Value); } // Photo.0xA20E (FocalPlaneXResolution/Rational/1) "5616000/1459" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FocalPlaneXResolution); Assert.IsNotNull(entry, "Entry 0xA20E missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(5616000, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1459, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0xA20F (FocalPlaneYResolution/Rational/1) "3744000/958" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FocalPlaneYResolution); Assert.IsNotNull(entry, "Entry 0xA20F missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(3744000, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(958, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0xA210 (FocalPlaneResolutionUnit/Short/1) "2" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FocalPlaneResolutionUnit); Assert.IsNotNull(entry, "Entry 0xA210 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Photo.0xA401 (CustomRendered/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.CustomRendered); Assert.IsNotNull(entry, "Entry 0xA401 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0xA402 (ExposureMode/Short/1) "1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureMode); Assert.IsNotNull(entry, "Entry 0xA402 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(1, (entry as ShortIFDEntry).Value); } // Photo.0xA403 (WhiteBalance/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.WhiteBalance); Assert.IsNotNull(entry, "Entry 0xA403 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0xA406 (SceneCaptureType/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.SceneCaptureType); Assert.IsNotNull(entry, "Entry 0xA406 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Image.0x8825 (GPSTag/SubIFD/1) "724" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.GPSIFD); Assert.IsNotNull(entry, "Entry 0x8825 missing in IFD 0"); Assert.IsNotNull(entry as SubIFDEntry, "Entry is not a sub IFD!"); } var gps = structure.GetEntry(0, (ushort)IFDEntryTag.GPSIFD) as SubIFDEntry; Assert.IsNotNull(gps, "GPS tag not found"); var gps_structure = gps.Structure; // GPSInfo.0x0000 (GPSVersionID/Byte/4) "2 2 0 0 " { var entry = gps_structure.GetEntry(0, (ushort)GPSEntryTag.GPSVersionID); Assert.IsNotNull(entry, "Entry 0x0000 missing in IFD 0"); Assert.IsNotNull(entry as ByteVectorIFDEntry, "Entry is not a byte array!"); var parsed_bytes = (entry as ByteVectorIFDEntry).Data.Data; var bytes = new byte [] { 2, 2, 0, 0 }; Assert.AreEqual(bytes, parsed_bytes); } // Thumbnail.0x0103 (Compression/Short/1) "6" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.Compression); Assert.IsNotNull(entry, "Entry 0x0103 missing in IFD 1"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(6, (entry as ShortIFDEntry).Value); } // Thumbnail.0x011A (XResolution/Rational/1) "72/1" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.XResolution); Assert.IsNotNull(entry, "Entry 0x011A missing in IFD 1"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(72, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Thumbnail.0x011B (YResolution/Rational/1) "72/1" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.YResolution); Assert.IsNotNull(entry, "Entry 0x011B missing in IFD 1"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(72, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Thumbnail.0x0128 (ResolutionUnit/Short/1) "2" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.ResolutionUnit); Assert.IsNotNull(entry, "Entry 0x0128 missing in IFD 1"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Thumbnail.0x0201 (JPEGInterchangeFormat/ThumbnailDataIFD/1) "836" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.JPEGInterchangeFormat); Assert.IsNotNull(entry, "Entry 0x0201 missing in IFD 1"); Assert.IsNotNull(entry as ThumbnailDataIFDEntry, "Entry is not a thumbnail IFD!"); } // Thumbnail.0x0202 (JPEGInterchangeFormatLength/Long/1) "4463" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.JPEGInterchangeFormatLength); Assert.IsNotNull(entry, "Entry 0x0202 missing in IFD 1"); Assert.IsNotNull(entry as LongIFDEntry, "Entry is not a long!"); Assert.AreEqual(4463, (entry as LongIFDEntry).Value); } // ---------- End of IFD tests ---------- // ---------- Start of XMP tests ---------- XmpTag xmp = file.GetTag(TagTypes.XMP) as XmpTag; // Xmp.tiff.Software (XmpText/46) "Microsoft Windows Photo Gallery 6.0.6000.16386" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.TIFF_NS, "Software"); Assert.IsNotNull(node); Assert.AreEqual("Microsoft Windows Photo Gallery 6.0.6000.16386", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.tiff.software (XmpText/46) "Microsoft Windows Photo Gallery 6.0.6000.16386" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.TIFF_NS, "software"); Assert.IsNotNull(node); Assert.AreEqual("Microsoft Windows Photo Gallery 6.0.6000.16386", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.xmp.CreatorTool (XmpText/49) "Adobe Photoshop Elements for Windows, version 2.0" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.XAP_NS, "CreatorTool"); Assert.IsNotNull(node); Assert.AreEqual("Adobe Photoshop Elements for Windows, version 2.0", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.xmp.creatortool (XmpText/46) "Microsoft Windows Photo Gallery 6.0.6000.16386" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.XAP_NS, "creatortool"); Assert.IsNotNull(node); Assert.AreEqual("Microsoft Windows Photo Gallery 6.0.6000.16386", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.xmpMM.DocumentID (XmpText/58) "adobe:docid:photoshop:f48fd669-42b3-11de-a9a9-b4912218066d" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.XAP_MM_NS, "DocumentID"); Assert.IsNotNull(node); Assert.AreEqual("adobe:docid:photoshop:f48fd669-42b3-11de-a9a9-b4912218066d", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.dc.subject (XmpBag/2) "TASI, 50v-juhlat" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.DC_NS, "subject"); Assert.IsNotNull(node); Assert.AreEqual(XmpNodeType.Bag, node.Type); Assert.AreEqual("", node.Value); Assert.AreEqual(2, node.Children.Count); var children_array = new System.Collections.Generic.List <string> (); foreach (var child in node.Children) { children_array.Add(child.Value); } Assert.IsTrue(children_array.Contains("TASI")); Assert.IsTrue(children_array.Contains("50v-juhlat")); } // ---------- End of XMP tests ---------- }
public void ValidateMetadataInvariants(Image.File file) { Assert.IsNotNull(file); // ---------- Start of IFD tests ---------- var tag = file.GetTag(TagTypes.TiffIFD) as IFDTag; Assert.IsNotNull(tag, "IFD tag not found"); var structure = tag.Structure; // Image.0x00FE (NewSubfileType/Long/1) "0" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.NewSubfileType); Assert.IsNotNull(entry, "Entry 0x00FE missing in IFD 0"); Assert.IsNotNull(entry as LongIFDEntry, "Entry is not a long!"); Assert.AreEqual(0, (entry as LongIFDEntry).Value); } // Image.0x0100 (ImageWidth/Short/1) "1360" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.ImageWidth); Assert.IsNotNull(entry, "Entry 0x0100 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(1360, (entry as ShortIFDEntry).Value); } // Image.0x0101 (ImageLength/Short/1) "1060" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.ImageLength); Assert.IsNotNull(entry, "Entry 0x0101 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(1060, (entry as ShortIFDEntry).Value); } // Image.0x0102 (BitsPerSample/Short/3) "8 8 8" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.BitsPerSample); Assert.IsNotNull(entry, "Entry 0x0102 missing in IFD 0"); Assert.IsNotNull(entry as ShortArrayIFDEntry, "Entry is not a short array!"); Assert.AreEqual(new ushort [] { 8, 8, 8 }, (entry as ShortArrayIFDEntry).Values); } // Image.0x0103 (Compression/Short/1) "5" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Compression); Assert.IsNotNull(entry, "Entry 0x0103 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(5, (entry as ShortIFDEntry).Value); } // Image.0x0106 (PhotometricInterpretation/Short/1) "2" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.PhotometricInterpretation); Assert.IsNotNull(entry, "Entry 0x0106 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Image.0x010D (DocumentName/Ascii/29) "/home/mike/sample_gimp1.tiff" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.DocumentName); Assert.IsNotNull(entry, "Entry 0x010D missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("/home/mike/sample_gimp1.tiff", (entry as StringIFDEntry).Value); } // Image.0x0111 (StripOffsets/StripOffsets/17) "8 92872 183535 274522 365281 454644 534266 611421 690373 775508 867104 965719 1071407 1175890 1280880 1386423 1477280" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.StripOffsets); Assert.IsNotNull(entry, "Entry 0x0111 missing in IFD 0"); Assert.IsNotNull(entry as StripOffsetsIFDEntry, "Entry is not a strip offsets entry!"); Assert.AreEqual(17, (entry as StripOffsetsIFDEntry).Values.Length); } // Image.0x0112 (Orientation/Short/1) "1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Orientation); Assert.IsNotNull(entry, "Entry 0x0112 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(1, (entry as ShortIFDEntry).Value); } // Image.0x0115 (SamplesPerPixel/Short/1) "3" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.SamplesPerPixel); Assert.IsNotNull(entry, "Entry 0x0115 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(3, (entry as ShortIFDEntry).Value); } // Image.0x0116 (RowsPerStrip/Short/1) "64" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.RowsPerStrip); Assert.IsNotNull(entry, "Entry 0x0116 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(64, (entry as ShortIFDEntry).Value); } // Image.0x0117 (StripByteCounts/Long/17) "92864 90663 90987 90759 89363 79622 77155 78952 85135 91596 98615 105688 104483 104990 105543 90857 44330" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.StripByteCounts); Assert.IsNotNull(entry, "Entry 0x0117 missing in IFD 0"); Assert.IsNotNull(entry as LongArrayIFDEntry, "Entry is not a long array!"); Assert.AreEqual(new long [] { 92864, 90663, 90987, 90759, 89363, 79622, 77155, 78952, 85135, 91596, 98615, 105688, 104483, 104990, 105543, 90857, 44330 }, (entry as LongArrayIFDEntry).Values); } // Image.0x011A (XResolution/Rational/1) "1207959552/16777216" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.XResolution); Assert.IsNotNull(entry, "Entry 0x011A missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(1207959552, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(16777216, (entry as RationalIFDEntry).Value.Denominator); } // Image.0x011B (YResolution/Rational/1) "1207959552/16777216" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.YResolution); Assert.IsNotNull(entry, "Entry 0x011B missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(1207959552, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(16777216, (entry as RationalIFDEntry).Value.Denominator); } // Image.0x011C (PlanarConfiguration/Short/1) "1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.PlanarConfiguration); Assert.IsNotNull(entry, "Entry 0x011C missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(1, (entry as ShortIFDEntry).Value); } // Image.0x0128 (ResolutionUnit/Short/1) "2" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.ResolutionUnit); Assert.IsNotNull(entry, "Entry 0x0128 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Image.0x013D (0x013d/Short/1) "2" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Predictor); Assert.IsNotNull(entry, "Entry 0x013D missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Image.0x8773 (InterColorProfile/Undefined/3140) "0 0 12 68 85 67 67 77 2 64 0 0 109 110 116 114 82 71 66 32 88 89 90 32 7 211 0 4 0 4 0 0 0 0 0 0 97 99 115 112 77 83 70 84 0 0 0 0 67 65 78 79 90 48 48 57 0 0 0 0 0 0 0 0 0 0 0 0 0 0 246 214 0 1 0 0 0 0 211 45 67 65 78 79 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 114 84 82 67 0 0 1 44 0 0 8 12 103 84 82 67 0 0 1 44 0 0 8 12 98 84 82 67 0 0 1 44 0 0 8 12 114 88 89 90 0 0 9 56 0 0 0 20 103 88 89 90 0 0 9 76 0 0 0 20 98 88 89 90 0 0 9 96 0 0 0 20 99 104 97 100 0 0 9 116 0 0 0 44 99 112 114 116 0 0 9 160 0 0 0 64 100 109 110 100 0 0 9 224 0 0 0 124 100 109 100 100 0 0 10 92 0 0 0 148 119 116 112 116 0 0 10 240 0 0 0 20 116 101 99 104 0 0 11 4 0 0 0 12 100 101 115 99 0 0 10 92 0 0 0 148 117 99 109 73 0 0 11 16 0 0 1 52 99 117 114 118 0 0 0 0 0 0 4 0 0 0 0 4 0 9 0 14 0 19 0 24 0 29 0 34 0 39 0 44 0 49 0 54 0 59 0 64 0 69 0 74 0 79 0 84 0 89 0 94 0 99 0 104 0 109 0 114 0 118 0 123 0 128 0 133 0 138 0 143 0 148 0 153 0 158 0 163 0 168 0 173 0 178 0 183 0 188 0 193 0 198 0 203 0 208 0 213 0 218 0 223 0 229 0 234 0 240 0 245 0 251 1 1 1 6 1 12 1 18 1 24 1 30 1 36 1 43 1 49 1 55 1 62 1 68 1 75 1 82 1 89 1 95 1 102 1 109 1 117 1 124 1 131 1 138 1 146 1 153 1 161 1 169 1 176 1 184 1 192 1 200 1 208 1 216 1 225 1 233 1 241 1 250 2 2 2 11 2 20 2 29 2 38 2 47 2 56 2 65 2 74 2 83 2 93 2 102 2 112 2 122 2 131 2 141 2 151 2 161 2 172 2 182 2 192 2 202 2 213 2 224 2 234 2 245 3 0 3 11 3 22 3 33 3 44 3 55 3 67 3 78 3 90 3 102 3 113 3 125 3 137 3 149 3 161 3 173 3 186 3 198 3 211 3 223 3 236 3 249 4 6 4 19 4 32 4 45 4 58 4 71 4 85 4 98 4 112 4 126 4 140 4 154 4 168 4 182 4 196 4 210 4 225 4 239 4 254 5 13 5 27 5 42 5 57 5 72 5 88 5 103 5 118 5 134 5 149 5 165 5 181 5 197 5 213 5 229 5 245 6 5 6 22 6 38 6 55 6 72 6 88 6 105 6 122 6 139 6 157 6 174 6 191 6 209 6 227 6 244 7 6 7 24 7 42 7 60 7 79 7 97 7 115 7 134 7 153 7 171 7 190 7 209 7 228 7 248 8 11 8 30 8 50 8 69 8 89 8 109 8 129 8 149 8 169 8 190 8 210 8 230 8 251 9 16 9 36 9 57 9 78 9 100 9 121 9 142 9 164 9 185 9 207 9 229 9 251 10 17 10 39 10 61 10 83 10 106 10 128 10 151 10 174 10 197 10 220 10 243 11 10 11 33 11 57 11 80 11 104 11 128 11 152 11 176 11 200 11 224 11 249 12 17 12 42 12 66 12 91 12 116 12 141 12 166 12 192 12 217 12 242 13 12 13 38 13 64 13 90 13 116 13 142 13 168 13 195 13 221 13 248 14 19 14 46 14 73 14 100 14 127 14 154 14 182 14 209 14 237 15 9 15 37 15 65 15 93 15 121 15 150 15 178 15 207 15 236 16 9 16 38 16 67 16 96 16 125 16 155 16 185 16 214 16 244 17 18 17 48 17 78 17 109 17 139 17 170 17 200 17 231 18 6 18 37 18 68 18 100 18 131 18 163 18 194 18 226 19 2 19 34 19 66 19 99 19 131 19 164 19 196 19 229 20 6 20 39 20 72 20 105 20 139 20 172 20 206 20 240 21 17 21 52 21 86 21 120 21 154 21 189 21 223 22 2 22 37 22 72 22 107 22 143 22 178 22 213 22 249 23 29 23 65 23 101 23 137 23 173 23 210 23 246 24 27 24 64 24 101 24 138 24 175 24 212 24 250 25 31 25 69 25 107 25 145 25 183 25 221 26 3 26 42 26 80 26 119 26 158 26 197 26 236 27 19 27 59 27 98 27 138 27 177 27 217 28 1 28 41 28 82 28 122 28 163 28 203 28 244 29 29 29 70 29 111 29 153 29 194 29 236 30 22 30 63 30 105 30 147 30 190 30 232 31 19 31 61 31 104 31 147 31 190 31 233 32 21 32 64 32 108 32 151 32 195 32 239 33 27 33 72 33 116 33 161 33 205 33 250 34 39 34 84 34 129 34 175 34 220 35 10 35 55 35 101 35 147 35 194 35 240 36 30 36 77 36 124 36 170 36 217 37 8 37 56 37 103 37 151 37 198 37 246 38 38 38 86 38 134 38 183 38 231 39 24 39 73 39 121 39 170 39 220 40 13 40 62 40 112 40 162 40 212 41 6 41 56 41 106 41 157 41 207 42 2 42 53 42 104 42 155 42 206 43 1 43 53 43 105 43 157 43 209 44 5 44 57 44 109 44 162 44 215 45 11 45 64 45 117 45 171 45 224 46 22 46 75 46 129 46 183 46 237 47 35 47 90 47 144 47 199 47 254 48 53 48 108 48 163 48 218 49 18 49 74 49 129 49 185 49 241 50 42 50 98 50 155 50 211 51 12 51 69 51 126 51 183 51 241 52 42 52 100 52 158 52 216 53 18 53 76 53 135 53 193 53 252 54 55 54 114 54 173 54 232 55 36 55 95 55 155 55 215 56 19 56 79 56 140 56 200 57 5 57 65 57 126 57 187 57 249 58 54 58 115 58 177 58 239 59 45 59 107 59 169 59 231 60 38 60 101 60 164 60 227 61 34 61 97 61 160 61 224 62 32 62 96 62 160 62 224 63 32 63 97 63 161 63 226 64 35 64 100 64 165 64 231 65 40 65 106 65 172 65 238 66 48 66 114 66 180 66 247 67 58 67 125 67 192 68 3 68 70 68 138 68 205 69 17 69 85 69 153 69 221 70 34 70 102 70 171 70 240 71 53 71 122 71 191 72 5 72 74 72 144 72 214 73 28 73 98 73 169 73 239 74 54 74 125 74 196 75 11 75 82 75 154 75 225 76 41 76 113 76 185 77 2 77 74 77 146 77 219 78 36 78 109 78 182 79 0 79 73 79 147 79 220 80 38 80 112 80 187 81 5 81 80 81 154 81 229 82 48 82 124 82 199 83 18 83 94 83 170 83 246 84 66 84 142 84 219 85 39 85 116 85 193 86 14 86 91 86 169 86 246 87 68 87 146 87 224 88 46 88 124 88 203 89 26 89 104 89 183 90 7 90 86 90 165 90 245 91 69 91 149 91 229 92 53 92 133 92 214 93 39 93 119 93 201 94 26 94 107 94 189 95 14 95 96 95 178 96 4 96 87 96 169 96 252 97 79 97 162 97 245 98 72 98 155 98 239 99 67 99 151 99 235 100 63 100 148 100 232 101 61 101 146 101 231 102 60 102 146 102 231 103 61 103 147 103 233 104 63 104 149 104 236 105 67 105 153 105 240 106 72 106 159 106 247 107 78 107 166 107 254 108 86 108 175 109 7 109 96 109 185 110 17 110 107 110 196 111 29 111 119 111 209 112 43 112 133 112 223 113 58 113 148 113 239 114 74 114 165 115 1 115 92 115 184 116 19 116 111 116 204 117 40 117 132 117 225 118 62 118 155 118 248 119 85 119 179 120 16 120 110 120 204 121 42 121 136 121 231 122 69 122 164 123 3 123 98 123 193 124 33 124 129 124 224 125 64 125 160 126 1 126 97 126 194 127 35 127 132 127 229 128 70 128 168 129 9 129 107 129 205 130 47 130 145 130 244 131 87 131 185 132 28 132 128 132 227 133 70 133 170 134 14 134 114 134 214 135 58 135 159 136 4 136 104 136 205 137 51 137 152 137 254 138 99 138 201 139 47 139 149 139 252 140 98 140 201 141 48 141 151 141 254 142 102 142 205 143 53 143 157 144 5 144 109 144 214 145 63 145 167 146 16 146 121 146 227 147 76 147 182 148 32 148 138 148 244 149 94 149 201 150 51 150 158 151 9 151 117 151 224 152 76 152 183 153 35 153 143 153 251 154 104 154 213 155 65 155 174 156 27 156 137 156 246 157 100 157 210 158 64 158 174 159 28 159 139 159 249 160 104 160 215 161 70 161 182 162 37 162 149 163 5 163 117 163 229 164 86 164 198 165 55 165 168 166 25 166 139 166 252 167 110 167 224 168 82 168 196 169 54 169 169 170 28 170 142 171 2 171 117 171 232 172 92 172 208 173 68 173 184 174 44 174 161 175 21 175 138 175 255 176 116 176 234 177 95 177 213 178 75 178 193 179 55 179 174 180 36 180 155 181 18 181 137 182 1 182 120 182 240 183 104 183 224 184 88 184 209 185 73 185 194 186 59 186 180 187 45 187 167 188 33 188 154 189 20 189 143 190 9 190 132 190 254 191 121 191 244 192 112 192 235 193 103 193 227 194 95 194 219 195 87 195 212 196 81 196 205 197 75 197 200 198 69 198 195 199 65 199 191 200 61 200 187 201 58 201 185 202 56 202 183 203 54 203 181 204 53 204 181 205 53 205 181 206 53 206 182 207 55 207 184 208 57 208 186 209 59 209 189 210 63 210 193 211 67 211 197 212 72 212 203 213 78 213 209 214 84 214 216 215 91 215 223 216 99 216 231 217 108 217 240 218 117 218 250 219 127 220 4 220 138 221 16 221 150 222 28 222 162 223 40 223 175 224 54 224 189 225 68 225 203 226 83 226 218 227 98 227 234 228 115 228 251 229 132 230 13 230 150 231 31 231 168 232 50 232 188 233 70 233 208 234 90 234 229 235 111 235 250 236 133 237 16 237 156 238 39 238 179 239 63 239 203 240 88 240 228 241 113 241 254 242 139 243 25 243 166 244 52 244 194 245 80 245 222 246 108 246 251 247 138 248 25 248 168 249 55 249 199 250 87 250 231 251 119 252 7 252 152 253 40 253 185 254 74 254 219 255 109 255 255 88 89 90 32 0 0 0 0 0 0 111 160 0 0 56 242 0 0 3 143 88 89 90 32 0 0 0 0 0 0 98 150 0 0 183 138 0 0 24 218 88 89 90 32 0 0 0 0 0 0 36 160 0 0 15 133 0 0 182 196 115 102 51 50 0 0 0 0 0 1 12 63 0 0 5 220 255 255 243 39 0 0 7 144 0 0 253 146 255 255 251 162 255 255 253 163 0 0 3 220 0 0 192 113 116 101 120 116 0 0 0 0 67 111 112 121 114 105 103 104 116 32 40 99 41 32 50 48 48 51 44 32 67 97 110 111 110 32 73 110 99 46 32 32 65 108 108 32 114 105 103 104 116 115 32 114 101 115 101 114 118 101 100 46 0 0 0 0 100 101 115 99 0 0 0 0 0 0 0 11 67 97 110 111 110 32 73 110 99 46 0 0 0 0 0 0 0 0 10 0 67 0 97 0 110 0 111 0 110 0 32 0 73 0 110 0 99 0 46 0 0 11 67 97 110 111 110 32 73 110 99 46 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 101 115 99 0 0 0 0 0 0 0 19 115 82 71 66 32 118 49 46 51 49 32 40 67 97 110 111 110 41 0 0 0 0 0 0 0 0 18 0 115 0 82 0 71 0 66 0 32 0 118 0 49 0 46 0 51 0 49 0 32 0 40 0 67 0 97 0 110 0 111 0 110 0 41 0 0 19 115 82 71 66 32 118 49 46 51 49 32 40 67 97 110 111 110 41 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 88 89 90 32 0 0 0 0 0 0 246 214 0 1 0 0 0 0 211 45 115 105 103 32 0 0 0 0 67 82 84 32 117 99 109 73 67 83 73 71 0 0 1 40 1 8 0 0 1 8 0 0 1 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 86 73 84 32 76 97 98 111 114 97 116 111 114 121 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 67 73 78 67 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 243 84 0 1 0 0 0 1 22 207 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 20 0 0 0 0 0 1 0 1 0 0 0 0 0 1 " { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.ICCProfile); Assert.IsNotNull(entry, "Entry 0x8773 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var bytes = new byte [] { 0, 0, 12, 68, 85, 67, 67, 77, 2, 64, 0, 0, 109, 110, 116, 114, 82, 71, 66, 32, 88, 89, 90, 32, 7, 211, 0, 4, 0, 4, 0, 0, 0, 0, 0, 0, 97, 99, 115, 112, 77, 83, 70, 84, 0, 0, 0, 0, 67, 65, 78, 79, 90, 48, 48, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 246, 214, 0, 1, 0, 0, 0, 0, 211, 45, 67, 65, 78, 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 114, 84, 82, 67, 0, 0, 1, 44, 0, 0, 8, 12, 103, 84, 82, 67, 0, 0, 1, 44, 0, 0, 8, 12, 98, 84, 82, 67, 0, 0, 1, 44, 0, 0, 8, 12, 114, 88, 89, 90, 0, 0, 9, 56, 0, 0, 0, 20, 103, 88, 89, 90, 0, 0, 9, 76, 0, 0, 0, 20, 98, 88, 89, 90, 0, 0, 9, 96, 0, 0, 0, 20, 99, 104, 97, 100, 0, 0, 9, 116, 0, 0, 0, 44, 99, 112, 114, 116, 0, 0, 9, 160, 0, 0, 0, 64, 100, 109, 110, 100, 0, 0, 9, 224, 0, 0, 0, 124, 100, 109, 100, 100, 0, 0, 10, 92, 0, 0, 0, 148, 119, 116, 112, 116, 0, 0, 10, 240, 0, 0, 0, 20, 116, 101, 99, 104, 0, 0, 11, 4, 0, 0, 0, 12, 100, 101, 115, 99, 0, 0, 10, 92, 0, 0, 0, 148, 117, 99, 109, 73, 0, 0, 11, 16, 0, 0, 1, 52, 99, 117, 114, 118, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 4, 0, 9, 0, 14, 0, 19, 0, 24, 0, 29, 0, 34, 0, 39, 0, 44, 0, 49, 0, 54, 0, 59, 0, 64, 0, 69, 0, 74, 0, 79, 0, 84, 0, 89, 0, 94, 0, 99, 0, 104, 0, 109, 0, 114, 0, 118, 0, 123, 0, 128, 0, 133, 0, 138, 0, 143, 0, 148, 0, 153, 0, 158, 0, 163, 0, 168, 0, 173, 0, 178, 0, 183, 0, 188, 0, 193, 0, 198, 0, 203, 0, 208, 0, 213, 0, 218, 0, 223, 0, 229, 0, 234, 0, 240, 0, 245, 0, 251, 1, 1, 1, 6, 1, 12, 1, 18, 1, 24, 1, 30, 1, 36, 1, 43, 1, 49, 1, 55, 1, 62, 1, 68, 1, 75, 1, 82, 1, 89, 1, 95, 1, 102, 1, 109, 1, 117, 1, 124, 1, 131, 1, 138, 1, 146, 1, 153, 1, 161, 1, 169, 1, 176, 1, 184, 1, 192, 1, 200, 1, 208, 1, 216, 1, 225, 1, 233, 1, 241, 1, 250, 2, 2, 2, 11, 2, 20, 2, 29, 2, 38, 2, 47, 2, 56, 2, 65, 2, 74, 2, 83, 2, 93, 2, 102, 2, 112, 2, 122, 2, 131, 2, 141, 2, 151, 2, 161, 2, 172, 2, 182, 2, 192, 2, 202, 2, 213, 2, 224, 2, 234, 2, 245, 3, 0, 3, 11, 3, 22, 3, 33, 3, 44, 3, 55, 3, 67, 3, 78, 3, 90, 3, 102, 3, 113, 3, 125, 3, 137, 3, 149, 3, 161, 3, 173, 3, 186, 3, 198, 3, 211, 3, 223, 3, 236, 3, 249, 4, 6, 4, 19, 4, 32, 4, 45, 4, 58, 4, 71, 4, 85, 4, 98, 4, 112, 4, 126, 4, 140, 4, 154, 4, 168, 4, 182, 4, 196, 4, 210, 4, 225, 4, 239, 4, 254, 5, 13, 5, 27, 5, 42, 5, 57, 5, 72, 5, 88, 5, 103, 5, 118, 5, 134, 5, 149, 5, 165, 5, 181, 5, 197, 5, 213, 5, 229, 5, 245, 6, 5, 6, 22, 6, 38, 6, 55, 6, 72, 6, 88, 6, 105, 6, 122, 6, 139, 6, 157, 6, 174, 6, 191, 6, 209, 6, 227, 6, 244, 7, 6, 7, 24, 7, 42, 7, 60, 7, 79, 7, 97, 7, 115, 7, 134, 7, 153, 7, 171, 7, 190, 7, 209, 7, 228, 7, 248, 8, 11, 8, 30, 8, 50, 8, 69, 8, 89, 8, 109, 8, 129, 8, 149, 8, 169, 8, 190, 8, 210, 8, 230, 8, 251, 9, 16, 9, 36, 9, 57, 9, 78, 9, 100, 9, 121, 9, 142, 9, 164, 9, 185, 9, 207, 9, 229, 9, 251, 10, 17, 10, 39, 10, 61, 10, 83, 10, 106, 10, 128, 10, 151, 10, 174, 10, 197, 10, 220, 10, 243, 11, 10, 11, 33, 11, 57, 11, 80, 11, 104, 11, 128, 11, 152, 11, 176, 11, 200, 11, 224, 11, 249, 12, 17, 12, 42, 12, 66, 12, 91, 12, 116, 12, 141, 12, 166, 12, 192, 12, 217, 12, 242, 13, 12, 13, 38, 13, 64, 13, 90, 13, 116, 13, 142, 13, 168, 13, 195, 13, 221, 13, 248, 14, 19, 14, 46, 14, 73, 14, 100, 14, 127, 14, 154, 14, 182, 14, 209, 14, 237, 15, 9, 15, 37, 15, 65, 15, 93, 15, 121, 15, 150, 15, 178, 15, 207, 15, 236, 16, 9, 16, 38, 16, 67, 16, 96, 16, 125, 16, 155, 16, 185, 16, 214, 16, 244, 17, 18, 17, 48, 17, 78, 17, 109, 17, 139, 17, 170, 17, 200, 17, 231, 18, 6, 18, 37, 18, 68, 18, 100, 18, 131, 18, 163, 18, 194, 18, 226, 19, 2, 19, 34, 19, 66, 19, 99, 19, 131, 19, 164, 19, 196, 19, 229, 20, 6, 20, 39, 20, 72, 20, 105, 20, 139, 20, 172, 20, 206, 20, 240, 21, 17, 21, 52, 21, 86, 21, 120, 21, 154, 21, 189, 21, 223, 22, 2, 22, 37, 22, 72, 22, 107, 22, 143, 22, 178, 22, 213, 22, 249, 23, 29, 23, 65, 23, 101, 23, 137, 23, 173, 23, 210, 23, 246, 24, 27, 24, 64, 24, 101, 24, 138, 24, 175, 24, 212, 24, 250, 25, 31, 25, 69, 25, 107, 25, 145, 25, 183, 25, 221, 26, 3, 26, 42, 26, 80, 26, 119, 26, 158, 26, 197, 26, 236, 27, 19, 27, 59, 27, 98, 27, 138, 27, 177, 27, 217, 28, 1, 28, 41, 28, 82, 28, 122, 28, 163, 28, 203, 28, 244, 29, 29, 29, 70, 29, 111, 29, 153, 29, 194, 29, 236, 30, 22, 30, 63, 30, 105, 30, 147, 30, 190, 30, 232, 31, 19, 31, 61, 31, 104, 31, 147, 31, 190, 31, 233, 32, 21, 32, 64, 32, 108, 32, 151, 32, 195, 32, 239, 33, 27, 33, 72, 33, 116, 33, 161, 33, 205, 33, 250, 34, 39, 34, 84, 34, 129, 34, 175, 34, 220, 35, 10, 35, 55, 35, 101, 35, 147, 35, 194, 35, 240, 36, 30, 36, 77, 36, 124, 36, 170, 36, 217, 37, 8, 37, 56, 37, 103, 37, 151, 37, 198, 37, 246, 38, 38, 38, 86, 38, 134, 38, 183, 38, 231, 39, 24, 39, 73, 39, 121, 39, 170, 39, 220, 40, 13, 40, 62, 40, 112, 40, 162, 40, 212, 41, 6, 41, 56, 41, 106, 41, 157, 41, 207, 42, 2, 42, 53, 42, 104, 42, 155, 42, 206, 43, 1, 43, 53, 43, 105, 43, 157, 43, 209, 44, 5, 44, 57, 44, 109, 44, 162, 44, 215, 45, 11, 45, 64, 45, 117, 45, 171, 45, 224, 46, 22, 46, 75, 46, 129, 46, 183, 46, 237, 47, 35, 47, 90, 47, 144, 47, 199, 47, 254, 48, 53, 48, 108, 48, 163, 48, 218, 49, 18, 49, 74, 49, 129, 49, 185, 49, 241, 50, 42, 50, 98, 50, 155, 50, 211, 51, 12, 51, 69, 51, 126, 51, 183, 51, 241, 52, 42, 52, 100, 52, 158, 52, 216, 53, 18, 53, 76, 53, 135, 53, 193, 53, 252, 54, 55, 54, 114, 54, 173, 54, 232, 55, 36, 55, 95, 55, 155, 55, 215, 56, 19, 56, 79, 56, 140, 56, 200, 57, 5, 57, 65, 57, 126, 57, 187, 57, 249, 58, 54, 58, 115, 58, 177, 58, 239, 59, 45, 59, 107, 59, 169, 59, 231, 60, 38, 60, 101, 60, 164, 60, 227, 61, 34, 61, 97, 61, 160, 61, 224, 62, 32, 62, 96, 62, 160, 62, 224, 63, 32, 63, 97, 63, 161, 63, 226, 64, 35, 64, 100, 64, 165, 64, 231, 65, 40, 65, 106, 65, 172, 65, 238, 66, 48, 66, 114, 66, 180, 66, 247, 67, 58, 67, 125, 67, 192, 68, 3, 68, 70, 68, 138, 68, 205, 69, 17, 69, 85, 69, 153, 69, 221, 70, 34, 70, 102, 70, 171, 70, 240, 71, 53, 71, 122, 71, 191, 72, 5, 72, 74, 72, 144, 72, 214, 73, 28, 73, 98, 73, 169, 73, 239, 74, 54, 74, 125, 74, 196, 75, 11, 75, 82, 75, 154, 75, 225, 76, 41, 76, 113, 76, 185, 77, 2, 77, 74, 77, 146, 77, 219, 78, 36, 78, 109, 78, 182, 79, 0, 79, 73, 79, 147, 79, 220, 80, 38, 80, 112, 80, 187, 81, 5, 81, 80, 81, 154, 81, 229, 82, 48, 82, 124, 82, 199, 83, 18, 83, 94, 83, 170, 83, 246, 84, 66, 84, 142, 84, 219, 85, 39, 85, 116, 85, 193, 86, 14, 86, 91, 86, 169, 86, 246, 87, 68, 87, 146, 87, 224, 88, 46, 88, 124, 88, 203, 89, 26, 89, 104, 89, 183, 90, 7, 90, 86, 90, 165, 90, 245, 91, 69, 91, 149, 91, 229, 92, 53, 92, 133, 92, 214, 93, 39, 93, 119, 93, 201, 94, 26, 94, 107, 94, 189, 95, 14, 95, 96, 95, 178, 96, 4, 96, 87, 96, 169, 96, 252, 97, 79, 97, 162, 97, 245, 98, 72, 98, 155, 98, 239, 99, 67, 99, 151, 99, 235, 100, 63, 100, 148, 100, 232, 101, 61, 101, 146, 101, 231, 102, 60, 102, 146, 102, 231, 103, 61, 103, 147, 103, 233, 104, 63, 104, 149, 104, 236, 105, 67, 105, 153, 105, 240, 106, 72, 106, 159, 106, 247, 107, 78, 107, 166, 107, 254, 108, 86, 108, 175, 109, 7, 109, 96, 109, 185, 110, 17, 110, 107, 110, 196, 111, 29, 111, 119, 111, 209, 112, 43, 112, 133, 112, 223, 113, 58, 113, 148, 113, 239, 114, 74, 114, 165, 115, 1, 115, 92, 115, 184, 116, 19, 116, 111, 116, 204, 117, 40, 117, 132, 117, 225, 118, 62, 118, 155, 118, 248, 119, 85, 119, 179, 120, 16, 120, 110, 120, 204, 121, 42, 121, 136, 121, 231, 122, 69, 122, 164, 123, 3, 123, 98, 123, 193, 124, 33, 124, 129, 124, 224, 125, 64, 125, 160, 126, 1, 126, 97, 126, 194, 127, 35, 127, 132, 127, 229, 128, 70, 128, 168, 129, 9, 129, 107, 129, 205, 130, 47, 130, 145, 130, 244, 131, 87, 131, 185, 132, 28, 132, 128, 132, 227, 133, 70, 133, 170, 134, 14, 134, 114, 134, 214, 135, 58, 135, 159, 136, 4, 136, 104, 136, 205, 137, 51, 137, 152, 137, 254, 138, 99, 138, 201, 139, 47, 139, 149, 139, 252, 140, 98, 140, 201, 141, 48, 141, 151, 141, 254, 142, 102, 142, 205, 143, 53, 143, 157, 144, 5, 144, 109, 144, 214, 145, 63, 145, 167, 146, 16, 146, 121, 146, 227, 147, 76, 147, 182, 148, 32, 148, 138, 148, 244, 149, 94, 149, 201, 150, 51, 150, 158, 151, 9, 151, 117, 151, 224, 152, 76, 152, 183, 153, 35, 153, 143, 153, 251, 154, 104, 154, 213, 155, 65, 155, 174, 156, 27, 156, 137, 156, 246, 157, 100, 157, 210, 158, 64, 158, 174, 159, 28, 159, 139, 159, 249, 160, 104, 160, 215, 161, 70, 161, 182, 162, 37, 162, 149, 163, 5, 163, 117, 163, 229, 164, 86, 164, 198, 165, 55, 165, 168, 166, 25, 166, 139, 166, 252, 167, 110, 167, 224, 168, 82, 168, 196, 169, 54, 169, 169, 170, 28, 170, 142, 171, 2, 171, 117, 171, 232, 172, 92, 172, 208, 173, 68, 173, 184, 174, 44, 174, 161, 175, 21, 175, 138, 175, 255, 176, 116, 176, 234, 177, 95, 177, 213, 178, 75, 178, 193, 179, 55, 179, 174, 180, 36, 180, 155, 181, 18, 181, 137, 182, 1, 182, 120, 182, 240, 183, 104, 183, 224, 184, 88, 184, 209, 185, 73, 185, 194, 186, 59, 186, 180, 187, 45, 187, 167, 188, 33, 188, 154, 189, 20, 189, 143, 190, 9, 190, 132, 190, 254, 191, 121, 191, 244, 192, 112, 192, 235, 193, 103, 193, 227, 194, 95, 194, 219, 195, 87, 195, 212, 196, 81, 196, 205, 197, 75, 197, 200, 198, 69, 198, 195, 199, 65, 199, 191, 200, 61, 200, 187, 201, 58, 201, 185, 202, 56, 202, 183, 203, 54, 203, 181, 204, 53, 204, 181, 205, 53, 205, 181, 206, 53, 206, 182, 207, 55, 207, 184, 208, 57, 208, 186, 209, 59, 209, 189, 210, 63, 210, 193, 211, 67, 211, 197, 212, 72, 212, 203, 213, 78, 213, 209, 214, 84, 214, 216, 215, 91, 215, 223, 216, 99, 216, 231, 217, 108, 217, 240, 218, 117, 218, 250, 219, 127, 220, 4, 220, 138, 221, 16, 221, 150, 222, 28, 222, 162, 223, 40, 223, 175, 224, 54, 224, 189, 225, 68, 225, 203, 226, 83, 226, 218, 227, 98, 227, 234, 228, 115, 228, 251, 229, 132, 230, 13, 230, 150, 231, 31, 231, 168, 232, 50, 232, 188, 233, 70, 233, 208, 234, 90, 234, 229, 235, 111, 235, 250, 236, 133, 237, 16, 237, 156, 238, 39, 238, 179, 239, 63, 239, 203, 240, 88, 240, 228, 241, 113, 241, 254, 242, 139, 243, 25, 243, 166, 244, 52, 244, 194, 245, 80, 245, 222, 246, 108, 246, 251, 247, 138, 248, 25, 248, 168, 249, 55, 249, 199, 250, 87, 250, 231, 251, 119, 252, 7, 252, 152, 253, 40, 253, 185, 254, 74, 254, 219, 255, 109, 255, 255, 88, 89, 90, 32, 0, 0, 0, 0, 0, 0, 111, 160, 0, 0, 56, 242, 0, 0, 3, 143, 88, 89, 90, 32, 0, 0, 0, 0, 0, 0, 98, 150, 0, 0, 183, 138, 0, 0, 24, 218, 88, 89, 90, 32, 0, 0, 0, 0, 0, 0, 36, 160, 0, 0, 15, 133, 0, 0, 182, 196, 115, 102, 51, 50, 0, 0, 0, 0, 0, 1, 12, 63, 0, 0, 5, 220, 255, 255, 243, 39, 0, 0, 7, 144, 0, 0, 253, 146, 255, 255, 251, 162, 255, 255, 253, 163, 0, 0, 3, 220, 0, 0, 192, 113, 116, 101, 120, 116, 0, 0, 0, 0, 67, 111, 112, 121, 114, 105, 103, 104, 116, 32, 40, 99, 41, 32, 50, 48, 48, 51, 44, 32, 67, 97, 110, 111, 110, 32, 73, 110, 99, 46, 32, 32, 65, 108, 108, 32, 114, 105, 103, 104, 116, 115, 32, 114, 101, 115, 101, 114, 118, 101, 100, 46, 0, 0, 0, 0, 100, 101, 115, 99, 0, 0, 0, 0, 0, 0, 0, 11, 67, 97, 110, 111, 110, 32, 73, 110, 99, 46, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 67, 0, 97, 0, 110, 0, 111, 0, 110, 0, 32, 0, 73, 0, 110, 0, 99, 0, 46, 0, 0, 11, 67, 97, 110, 111, 110, 32, 73, 110, 99, 46, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 101, 115, 99, 0, 0, 0, 0, 0, 0, 0, 19, 115, 82, 71, 66, 32, 118, 49, 46, 51, 49, 32, 40, 67, 97, 110, 111, 110, 41, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 115, 0, 82, 0, 71, 0, 66, 0, 32, 0, 118, 0, 49, 0, 46, 0, 51, 0, 49, 0, 32, 0, 40, 0, 67, 0, 97, 0, 110, 0, 111, 0, 110, 0, 41, 0, 0, 19, 115, 82, 71, 66, 32, 118, 49, 46, 51, 49, 32, 40, 67, 97, 110, 111, 110, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 88, 89, 90, 32, 0, 0, 0, 0, 0, 0, 246, 214, 0, 1, 0, 0, 0, 0, 211, 45, 115, 105, 103, 32, 0, 0, 0, 0, 67, 82, 84, 32, 117, 99, 109, 73, 67, 83, 73, 71, 0, 0, 1, 40, 1, 8, 0, 0, 1, 8, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 86, 73, 84, 32, 76, 97, 98, 111, 114, 97, 116, 111, 114, 121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 73, 78, 67, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 243, 84, 0, 1, 0, 0, 0, 1, 22, 207, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1 }; var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; Assert.AreEqual(bytes, parsed_bytes); } // ---------- End of IFD tests ---------- }
public void ValidateMetadataInvariants(Image.File file) { Assert.IsNotNull(file); // ---------- Start of IFD tests ---------- var tag = file.GetTag(TagTypes.TiffIFD) as IFDTag; Assert.IsNotNull(tag, "IFD tag not found"); var structure = tag.Structure; // Image.0x010F (Make/Ascii/18) "NIKON CORPORATION" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Make); Assert.IsNotNull(entry, "Entry 0x010F missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("NIKON CORPORATION", (entry as StringIFDEntry).Value); } // Image.0x0110 (Model/Ascii/10) "NIKON D80" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Model); Assert.IsNotNull(entry, "Entry 0x0110 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("NIKON D80", (entry as StringIFDEntry).Value); } // Image.0x0112 (Orientation/Short/1) "1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Orientation); Assert.IsNotNull(entry, "Entry 0x0112 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(1, (entry as ShortIFDEntry).Value); } // Image.0x011B (YResolution/Rational/1) "300/1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.YResolution); Assert.IsNotNull(entry, "Entry 0x011B missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(300, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Image.0x0128 (ResolutionUnit/Short/1) "2" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.ResolutionUnit); Assert.IsNotNull(entry, "Entry 0x0128 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Image.0x0131 (Software/Ascii/11) "Picasa 3.0" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Software); Assert.IsNotNull(entry, "Entry 0x0131 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("Picasa 3.0", (entry as StringIFDEntry).Value); } // Image.0x0132 (DateTime/Ascii/20) "2008:04:06 16:07:52" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.DateTime); Assert.IsNotNull(entry, "Entry 0x0132 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("2008:04:06 16:07:52", (entry as StringIFDEntry).Value); } // Image.0x0213 (YCbCrPositioning/Short/1) "2" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.YCbCrPositioning); Assert.IsNotNull(entry, "Entry 0x0213 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Image.0x8769 (ExifTag/SubIFD/1) "210" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.ExifIFD); Assert.IsNotNull(entry, "Entry 0x8769 missing in IFD 0"); Assert.IsNotNull(entry as SubIFDEntry, "Entry is not a sub IFD!"); } var exif = structure.GetEntry(0, (ushort)IFDEntryTag.ExifIFD) as SubIFDEntry; Assert.IsNotNull(exif, "Exif tag not found"); var exif_structure = exif.Structure; // Photo.0x829A (ExposureTime/Rational/1) "10/5000" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureTime); Assert.IsNotNull(entry, "Entry 0x829A missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(10, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(5000, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x829D (FNumber/Rational/1) "110/10" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FNumber); Assert.IsNotNull(entry, "Entry 0x829D missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(110, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(10, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x8822 (ExposureProgram/Short/1) "2" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureProgram); Assert.IsNotNull(entry, "Entry 0x8822 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Photo.0x8827 (ISOSpeedRatings/Short/1) "400" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ISOSpeedRatings); Assert.IsNotNull(entry, "Entry 0x8827 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(400, (entry as ShortIFDEntry).Value); } // Photo.0x9000 (ExifVersion/Undefined/4) "48 50 50 49" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExifVersion); Assert.IsNotNull(entry, "Entry 0x9000 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 48, 50, 50, 49 }; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0x9003 (DateTimeOriginal/Ascii/20) "2008:04:06 16:07:52" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.DateTimeOriginal); Assert.IsNotNull(entry, "Entry 0x9003 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("2008:04:06 16:07:52", (entry as StringIFDEntry).Value); } // Photo.0x9004 (DateTimeDigitized/Ascii/20) "2008:04:06 16:07:52" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.DateTimeDigitized); Assert.IsNotNull(entry, "Entry 0x9004 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("2008:04:06 16:07:52", (entry as StringIFDEntry).Value); } // Photo.0x9101 (ComponentsConfiguration/Undefined/4) "1 2 3 0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ComponentsConfiguration); Assert.IsNotNull(entry, "Entry 0x9101 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 1, 2, 3, 0 }; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0x9102 (CompressedBitsPerPixel/Rational/1) "4/1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.CompressedBitsPerPixel); Assert.IsNotNull(entry, "Entry 0x9102 missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(4, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x9204 (ExposureBiasValue/SRational/1) "2/6" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureBiasValue); Assert.IsNotNull(entry, "Entry 0x9204 missing in IFD 0"); Assert.IsNotNull(entry as SRationalIFDEntry, "Entry is not a srational!"); Assert.AreEqual(2, (entry as SRationalIFDEntry).Value.Numerator); Assert.AreEqual(6, (entry as SRationalIFDEntry).Value.Denominator); } // Photo.0x9205 (MaxApertureValue/Rational/1) "37/10" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.MaxApertureValue); Assert.IsNotNull(entry, "Entry 0x9205 missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(37, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(10, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x9207 (MeteringMode/Short/1) "5" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.MeteringMode); Assert.IsNotNull(entry, "Entry 0x9207 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(5, (entry as ShortIFDEntry).Value); } // Photo.0x9208 (LightSource/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.LightSource); Assert.IsNotNull(entry, "Entry 0x9208 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0x9209 (Flash/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.Flash); Assert.IsNotNull(entry, "Entry 0x9209 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0x920A (FocalLength/Rational/1) "200/10" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FocalLength); Assert.IsNotNull(entry, "Entry 0x920A missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(200, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(10, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x9286 (UserComment/UserComment/44) "charset="Ascii" " { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.UserComment); Assert.IsNotNull(entry, "Entry 0x9286 missing in IFD 0"); Assert.IsNotNull(entry as UserCommentIFDEntry, "Entry is not a user comment!"); Assert.AreEqual("", (entry as UserCommentIFDEntry).Value.Trim()); } // Photo.0x9290 (SubSecTime/Ascii/3) "10" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.SubsecTime); Assert.IsNotNull(entry, "Entry 0x9290 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("10", (entry as StringIFDEntry).Value); } // Photo.0x9291 (SubSecTimeOriginal/Ascii/3) "10" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.SubsecTimeOriginal); Assert.IsNotNull(entry, "Entry 0x9291 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("10", (entry as StringIFDEntry).Value); } // Photo.0x9292 (SubSecTimeDigitized/Ascii/3) "10" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.SubsecTimeDigitized); Assert.IsNotNull(entry, "Entry 0x9292 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("10", (entry as StringIFDEntry).Value); } // Photo.0xA000 (FlashpixVersion/Undefined/4) "48 49 48 48" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FlashpixVersion); Assert.IsNotNull(entry, "Entry 0xA000 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 48, 49, 48, 48 }; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0xA001 (ColorSpace/Short/1) "1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ColorSpace); Assert.IsNotNull(entry, "Entry 0xA001 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(1, (entry as ShortIFDEntry).Value); } // Photo.0xA002 (PixelXDimension/Short/1) "3872" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.PixelXDimension); Assert.IsNotNull(entry, "Entry 0xA002 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(3872, (entry as ShortIFDEntry).Value); } // Photo.0xA003 (PixelYDimension/Short/1) "2592" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.PixelYDimension); Assert.IsNotNull(entry, "Entry 0xA003 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2592, (entry as ShortIFDEntry).Value); } // Photo.0xA005 (InteroperabilityTag/SubIFD/1) "878" { var entry = exif_structure.GetEntry(0, (ushort)IFDEntryTag.InteroperabilityIFD); Assert.IsNotNull(entry, "Entry 0xA005 missing in IFD 0"); Assert.IsNotNull(entry as SubIFDEntry, "Entry is not a sub IFD!"); } var iop = exif_structure.GetEntry(0, (ushort)IFDEntryTag.InteroperabilityIFD) as SubIFDEntry; Assert.IsNotNull(iop, "Iop tag not found"); var iop_structure = iop.Structure; // Iop.0x0002 (InteroperabilityVersion/Undefined/4) "48 49 48 48" { var entry = iop_structure.GetEntry(0, (ushort)IOPEntryTag.InteroperabilityVersion); Assert.IsNotNull(entry, "Entry 0x0002 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 48, 49, 48, 48 }; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0xA217 (SensingMethod/Short/1) "2" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.SensingMethod); Assert.IsNotNull(entry, "Entry 0xA217 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Photo.0xA300 (FileSource/Undefined/1) "3" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FileSource); Assert.IsNotNull(entry, "Entry 0xA300 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 3 }; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0xA301 (SceneType/Undefined/1) "1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.SceneType); Assert.IsNotNull(entry, "Entry 0xA301 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 1 }; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0xA302 (CFAPattern/Undefined/8) "0 2 0 2 1 2 0 1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.CFAPattern2); Assert.IsNotNull(entry, "Entry 0xA302 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 0, 2, 0, 2, 1, 2, 0, 1 }; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0xA401 (CustomRendered/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.CustomRendered); Assert.IsNotNull(entry, "Entry 0xA401 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0xA402 (ExposureMode/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureMode); Assert.IsNotNull(entry, "Entry 0xA402 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0xA403 (WhiteBalance/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.WhiteBalance); Assert.IsNotNull(entry, "Entry 0xA403 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0xA404 (DigitalZoomRatio/Rational/1) "1/1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.DigitalZoomRatio); Assert.IsNotNull(entry, "Entry 0xA404 missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0xA405 (FocalLengthIn35mmFilm/Short/1) "30" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FocalLengthIn35mmFilm); Assert.IsNotNull(entry, "Entry 0xA405 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(30, (entry as ShortIFDEntry).Value); } // Photo.0xA406 (SceneCaptureType/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.SceneCaptureType); Assert.IsNotNull(entry, "Entry 0xA406 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0xA407 (GainControl/Short/1) "1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.GainControl); Assert.IsNotNull(entry, "Entry 0xA407 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(1, (entry as ShortIFDEntry).Value); } // Photo.0xA408 (Contrast/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.Contrast); Assert.IsNotNull(entry, "Entry 0xA408 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0xA409 (Saturation/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.Saturation); Assert.IsNotNull(entry, "Entry 0xA409 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0xA40A (Sharpness/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.Sharpness); Assert.IsNotNull(entry, "Entry 0xA40A missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0xA40C (SubjectDistanceRange/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.SubjectDistanceRange); Assert.IsNotNull(entry, "Entry 0xA40C missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0xA420 (ImageUniqueID/Ascii/33) "dcf14c4dffe0b08900c88aae23f46199" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ImageUniqueID); Assert.IsNotNull(entry, "Entry 0xA420 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("dcf14c4dffe0b08900c88aae23f46199", (entry as StringIFDEntry).Value); } // Thumbnail.0x0103 (Compression/Short/1) "6" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.Compression); Assert.IsNotNull(entry, "Entry 0x0103 missing in IFD 1"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(6, (entry as ShortIFDEntry).Value); } // Thumbnail.0x011A (XResolution/Rational/1) "300/1" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.XResolution); Assert.IsNotNull(entry, "Entry 0x011A missing in IFD 1"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(300, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Thumbnail.0x011B (YResolution/Rational/1) "300/1" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.YResolution); Assert.IsNotNull(entry, "Entry 0x011B missing in IFD 1"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(300, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Thumbnail.0x0128 (ResolutionUnit/Short/1) "2" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.ResolutionUnit); Assert.IsNotNull(entry, "Entry 0x0128 missing in IFD 1"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Thumbnail.0x0201 (JPEGInterchangeFormat/ThumbnailDataIFD/1) "1014" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.JPEGInterchangeFormat); Assert.IsNotNull(entry, "Entry 0x0201 missing in IFD 1"); Assert.IsNotNull(entry as ThumbnailDataIFDEntry, "Entry is not a thumbnail IFD!"); } // Thumbnail.0x0202 (JPEGInterchangeFormatLength/Long/1) "9624" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.JPEGInterchangeFormatLength); Assert.IsNotNull(entry, "Entry 0x0202 missing in IFD 1"); Assert.IsNotNull(entry as LongIFDEntry, "Entry is not a long!"); Assert.AreEqual(9624, (entry as LongIFDEntry).Value); } // Thumbnail.0x0213 (YCbCrPositioning/Short/1) "2" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.YCbCrPositioning); Assert.IsNotNull(entry, "Entry 0x0213 missing in IFD 1"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // ---------- End of IFD tests ---------- }
public void ValidateMetadataInvariants(Image.File file) { Assert.IsNotNull(file); // This file doesn't have an orientation tag, we had a bug that causes // an exception when looking it up. Test it here. Assert.AreEqual(ImageOrientation.None, file.ImageTag.Orientation); // ---------- Start of IFD tests ---------- var tag = file.GetTag(TagTypes.TiffIFD) as IFDTag; Assert.IsNotNull(tag, "IFD tag not found"); var structure = tag.Structure; // Image.0x010F (Make/Ascii/6) "Canon" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Make); Assert.IsNotNull(entry, "Entry 0x010F missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("Canon", (entry as StringIFDEntry).Value); } // Image.0x0110 (Model/Ascii/15) "Canon EOS 450D" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Model); Assert.IsNotNull(entry, "Entry 0x0110 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("Canon EOS 450D", (entry as StringIFDEntry).Value); } // Image.0x011A (XResolution/Rational/1) "300/1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.XResolution); Assert.IsNotNull(entry, "Entry 0x011A missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(300, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Image.0x011B (YResolution/Rational/1) "300/1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.YResolution); Assert.IsNotNull(entry, "Entry 0x011B missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(300, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Image.0x0128 (ResolutionUnit/Short/1) "2" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.ResolutionUnit); Assert.IsNotNull(entry, "Entry 0x0128 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Image.0x0132 (DateTime/Ascii/20) "2010:02:08 11:37:33" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.DateTime); Assert.IsNotNull(entry, "Entry 0x0132 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("2010:02:08 11:37:33", (entry as StringIFDEntry).Value); } // Image.0x013B (Artist/Ascii/17) "Ruben Vermeersch" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Artist); Assert.IsNotNull(entry, "Entry 0x013B missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("Ruben Vermeersch", (entry as StringIFDEntry).Value); } // Image.0x8769 (ExifTag/SubIFD/1) "186" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.ExifIFD); Assert.IsNotNull(entry, "Entry 0x8769 missing in IFD 0"); Assert.IsNotNull(entry as SubIFDEntry, "Entry is not a sub IFD!"); } var exif = structure.GetEntry(0, (ushort)IFDEntryTag.ExifIFD) as SubIFDEntry; Assert.IsNotNull(exif, "Exif tag not found"); var exif_structure = exif.Structure; // Photo.0x829A (ExposureTime/Rational/1) "1/60" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureTime); Assert.IsNotNull(entry, "Entry 0x829A missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(60, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x829D (FNumber/Rational/1) "32/10" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FNumber); Assert.IsNotNull(entry, "Entry 0x829D missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(32, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(10, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x8822 (ExposureProgram/Short/1) "3" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureProgram); Assert.IsNotNull(entry, "Entry 0x8822 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(3, (entry as ShortIFDEntry).Value); } // Photo.0x8827 (ISOSpeedRatings/Short/1) "1600" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ISOSpeedRatings); Assert.IsNotNull(entry, "Entry 0x8827 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(1600, (entry as ShortIFDEntry).Value); } // Photo.0x9000 (ExifVersion/Undefined/4) "48 50 50 49 " { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExifVersion); Assert.IsNotNull(entry, "Entry 0x9000 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var bytes = new byte [] { 48, 50, 50, 49 }; var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0x9003 (DateTimeOriginal/Ascii/20) "2010:02:06 10:57:22" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.DateTimeOriginal); Assert.IsNotNull(entry, "Entry 0x9003 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("2010:02:06 10:57:22", (entry as StringIFDEntry).Value); } // Photo.0x9004 (DateTimeDigitized/Ascii/20) "2010:02:06 10:57:22" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.DateTimeDigitized); Assert.IsNotNull(entry, "Entry 0x9004 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("2010:02:06 10:57:22", (entry as StringIFDEntry).Value); } // Photo.0x9201 (ShutterSpeedValue/SRational/1) "5906891/1000000" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ShutterSpeedValue); Assert.IsNotNull(entry, "Entry 0x9201 missing in IFD 0"); Assert.IsNotNull(entry as SRationalIFDEntry, "Entry is not a srational!"); Assert.AreEqual(5906891, (entry as SRationalIFDEntry).Value.Numerator); Assert.AreEqual(1000000, (entry as SRationalIFDEntry).Value.Denominator); } // Photo.0x9202 (ApertureValue/Rational/1) "3356144/1000000" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ApertureValue); Assert.IsNotNull(entry, "Entry 0x9202 missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(3356144, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1000000, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x9204 (ExposureBiasValue/SRational/1) "0/1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureBiasValue); Assert.IsNotNull(entry, "Entry 0x9204 missing in IFD 0"); Assert.IsNotNull(entry as SRationalIFDEntry, "Entry is not a srational!"); Assert.AreEqual(0, (entry as SRationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as SRationalIFDEntry).Value.Denominator); } // Photo.0x9205 (MaxApertureValue/Rational/1) "2/1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.MaxApertureValue); Assert.IsNotNull(entry, "Entry 0x9205 missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(2, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x9207 (MeteringMode/Short/1) "5" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.MeteringMode); Assert.IsNotNull(entry, "Entry 0x9207 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(5, (entry as ShortIFDEntry).Value); } // Photo.0x9209 (Flash/Short/1) "16" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.Flash); Assert.IsNotNull(entry, "Entry 0x9209 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(16, (entry as ShortIFDEntry).Value); } // Photo.0x920A (FocalLength/Rational/1) "35/1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FocalLength); Assert.IsNotNull(entry, "Entry 0x920A missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(35, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x9291 (SubSecTimeOriginal/Ascii/3) "02" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.SubsecTimeOriginal); Assert.IsNotNull(entry, "Entry 0x9291 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("02", (entry as StringIFDEntry).Value); } // Photo.0x9292 (SubSecTimeDigitized/Ascii/3) "02" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.SubsecTimeDigitized); Assert.IsNotNull(entry, "Entry 0x9292 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("02", (entry as StringIFDEntry).Value); } // Photo.0xA20E (FocalPlaneXResolution/Rational/1) "4272000/878" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FocalPlaneXResolution); Assert.IsNotNull(entry, "Entry 0xA20E missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(4272000, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(878, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0xA20F (FocalPlaneYResolution/Rational/1) "2848000/584" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FocalPlaneYResolution); Assert.IsNotNull(entry, "Entry 0xA20F missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(2848000, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(584, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0xA210 (FocalPlaneResolutionUnit/Short/1) "2" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FocalPlaneResolutionUnit); Assert.IsNotNull(entry, "Entry 0xA210 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Photo.0xA401 (CustomRendered/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.CustomRendered); Assert.IsNotNull(entry, "Entry 0xA401 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0xA402 (ExposureMode/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureMode); Assert.IsNotNull(entry, "Entry 0xA402 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0xA403 (WhiteBalance/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.WhiteBalance); Assert.IsNotNull(entry, "Entry 0xA403 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0xA406 (SceneCaptureType/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.SceneCaptureType); Assert.IsNotNull(entry, "Entry 0xA406 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Thumbnail.0x0103 (Compression/Short/1) "6" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.Compression); Assert.IsNotNull(entry, "Entry 0x0103 missing in IFD 1"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(6, (entry as ShortIFDEntry).Value); } // Thumbnail.0x011A (XResolution/Rational/1) "300/1" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.XResolution); Assert.IsNotNull(entry, "Entry 0x011A missing in IFD 1"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(300, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Thumbnail.0x011B (YResolution/Rational/1) "300/1" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.YResolution); Assert.IsNotNull(entry, "Entry 0x011B missing in IFD 1"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(300, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Thumbnail.0x0128 (ResolutionUnit/Short/1) "2" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.ResolutionUnit); Assert.IsNotNull(entry, "Entry 0x0128 missing in IFD 1"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Thumbnail.0x0201 (JPEGInterchangeFormat/ThumbnailDataIFD/1) "674" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.JPEGInterchangeFormat); Assert.IsNotNull(entry, "Entry 0x0201 missing in IFD 1"); Assert.IsNotNull(entry as ThumbnailDataIFDEntry, "Entry is not a thumbnail IFD!"); } // Thumbnail.0x0202 (JPEGInterchangeFormatLength/Long/1) "17036" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.JPEGInterchangeFormatLength); Assert.IsNotNull(entry, "Entry 0x0202 missing in IFD 1"); Assert.IsNotNull(entry as LongIFDEntry, "Entry is not a long!"); Assert.AreEqual(17036, (entry as LongIFDEntry).Value); } // ---------- End of IFD tests ---------- }
public void ValidateMetadataInvariants(Image.File file) { Assert.IsNotNull(file); // ---------- Start of IFD tests ---------- var tag = file.GetTag(TagTypes.TiffIFD) as IFDTag; Assert.IsNotNull(tag, "IFD tag not found"); var structure = tag.Structure; // Image.0x010E (ImageDescription/Ascii/32) "OLYMPUS DIGITAL CAMERA " { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.ImageDescription); Assert.IsNotNull(entry, "Entry 0x010E missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("OLYMPUS DIGITAL CAMERA ", (entry as StringIFDEntry).Value); } // Image.0x010F (Make/Ascii/24) "OLYMPUS IMAGING CORP. " { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Make); Assert.IsNotNull(entry, "Entry 0x010F missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("OLYMPUS IMAGING CORP. ", (entry as StringIFDEntry).Value); } // Image.0x0110 (Model/Ascii/17) "u740,S740 " { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Model); Assert.IsNotNull(entry, "Entry 0x0110 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("u740,S740 ", (entry as StringIFDEntry).Value); } // Image.0x0112 (Orientation/Short/1) "1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Orientation); Assert.IsNotNull(entry, "Entry 0x0112 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(1, (entry as ShortIFDEntry).Value); } // Image.0x011A (XResolution/Rational/1) "314/1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.XResolution); Assert.IsNotNull(entry, "Entry 0x011A missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(314, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Image.0x011B (YResolution/Rational/1) "314/1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.YResolution); Assert.IsNotNull(entry, "Entry 0x011B missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(314, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Image.0x0128 (ResolutionUnit/Short/1) "2" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.ResolutionUnit); Assert.IsNotNull(entry, "Entry 0x0128 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Image.0x0131 (Software/Ascii/47) "Microsoft Windows Photo Gallery 6.0.6000.16386" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Software); Assert.IsNotNull(entry, "Entry 0x0131 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("Microsoft Windows Photo Gallery 6.0.6000.16386", (entry as StringIFDEntry).Value); } // Image.0x0132 (DateTime/Ascii/20) "2008:10:04 22:00:22" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.DateTime); Assert.IsNotNull(entry, "Entry 0x0132 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("2008:10:04 22:00:22", (entry as StringIFDEntry).Value); } // Image.0x0213 (YCbCrPositioning/Short/1) "2" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.YCbCrPositioning); Assert.IsNotNull(entry, "Entry 0x0213 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Image.0x8769 (ExifTag/SubIFD/1) "316" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.ExifIFD); Assert.IsNotNull(entry, "Entry 0x8769 missing in IFD 0"); Assert.IsNotNull(entry as SubIFDEntry, "Entry is not a sub IFD!"); } var exif = structure.GetEntry(0, (ushort)IFDEntryTag.ExifIFD) as SubIFDEntry; Assert.IsNotNull(exif, "Exif tag not found"); var exif_structure = exif.Structure; // Photo.0x829A (ExposureTime/Rational/1) "1/50" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureTime); Assert.IsNotNull(entry, "Entry 0x829A missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(50, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x829D (FNumber/Rational/1) "38/10" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FNumber); Assert.IsNotNull(entry, "Entry 0x829D missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(38, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(10, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x8822 (ExposureProgram/Short/1) "2" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureProgram); Assert.IsNotNull(entry, "Entry 0x8822 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Photo.0x8827 (ISOSpeedRatings/Short/1) "100" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ISOSpeedRatings); Assert.IsNotNull(entry, "Entry 0x8827 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(100, (entry as ShortIFDEntry).Value); } // Photo.0x9000 (ExifVersion/Undefined/4) "48 50 50 49" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExifVersion); Assert.IsNotNull(entry, "Entry 0x9000 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 48, 50, 50, 49 }; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0x9003 (DateTimeOriginal/Ascii/20) "2008:10:04 18:33:50" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.DateTimeOriginal); Assert.IsNotNull(entry, "Entry 0x9003 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("2008:10:04 18:33:50", (entry as StringIFDEntry).Value); } // Photo.0x9004 (DateTimeDigitized/Ascii/20) "2008:10:04 18:33:50" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.DateTimeDigitized); Assert.IsNotNull(entry, "Entry 0x9004 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("2008:10:04 18:33:50", (entry as StringIFDEntry).Value); } // Photo.0x9101 (ComponentsConfiguration/Undefined/4) "1 2 3 0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ComponentsConfiguration); Assert.IsNotNull(entry, "Entry 0x9101 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 1, 2, 3, 0 }; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0x9204 (ExposureBiasValue/SRational/1) "0/10" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureBiasValue); Assert.IsNotNull(entry, "Entry 0x9204 missing in IFD 0"); Assert.IsNotNull(entry as SRationalIFDEntry, "Entry is not a srational!"); Assert.AreEqual(0, (entry as SRationalIFDEntry).Value.Numerator); Assert.AreEqual(10, (entry as SRationalIFDEntry).Value.Denominator); } // Photo.0x9205 (MaxApertureValue/Rational/1) "344/100" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.MaxApertureValue); Assert.IsNotNull(entry, "Entry 0x9205 missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(344, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(100, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x9207 (MeteringMode/Short/1) "5" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.MeteringMode); Assert.IsNotNull(entry, "Entry 0x9207 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(5, (entry as ShortIFDEntry).Value); } // Photo.0x9208 (LightSource/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.LightSource); Assert.IsNotNull(entry, "Entry 0x9208 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0x9209 (Flash/Short/1) "25" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.Flash); Assert.IsNotNull(entry, "Entry 0x9209 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(25, (entry as ShortIFDEntry).Value); } // Photo.0x920A (FocalLength/Rational/1) "886/100" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FocalLength); Assert.IsNotNull(entry, "Entry 0x920A missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(886, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(100, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x927C (MakerNote/MakerNote/1622) "(Value ommitted)" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.MakerNote); Assert.IsNotNull(entry, "Entry 0x927C missing in IFD 0"); Assert.IsNotNull(entry as MakernoteIFDEntry, "Entry is not a makernote IFD!"); } // Photo.0xA000 (FlashpixVersion/Undefined/4) "48 49 48 48" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FlashpixVersion); Assert.IsNotNull(entry, "Entry 0xA000 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 48, 49, 48, 48 }; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0xA001 (ColorSpace/Short/1) "1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ColorSpace); Assert.IsNotNull(entry, "Entry 0xA001 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(1, (entry as ShortIFDEntry).Value); } // Photo.0xA002 (PixelXDimension/Long/1) "1536" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.PixelXDimension); Assert.IsNotNull(entry, "Entry 0xA002 missing in IFD 0"); Assert.IsNotNull(entry as LongIFDEntry, "Entry is not a long!"); Assert.AreEqual(1536, (entry as LongIFDEntry).Value); } // Photo.0xA003 (PixelYDimension/Long/1) "2048" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.PixelYDimension); Assert.IsNotNull(entry, "Entry 0xA003 missing in IFD 0"); Assert.IsNotNull(entry as LongIFDEntry, "Entry is not a long!"); Assert.AreEqual(2048, (entry as LongIFDEntry).Value); } // Photo.0xA005 (InteroperabilityTag/SubIFD/1) "2534" { var entry = exif_structure.GetEntry(0, (ushort)IFDEntryTag.InteroperabilityIFD); Assert.IsNotNull(entry, "Entry 0xA005 missing in IFD 0"); Assert.IsNotNull(entry as SubIFDEntry, "Entry is not a sub IFD!"); } var iop = exif_structure.GetEntry(0, (ushort)IFDEntryTag.InteroperabilityIFD) as SubIFDEntry; Assert.IsNotNull(iop, "Iop tag not found"); var iop_structure = iop.Structure; // Iop.0x0001 (InteroperabilityIndex/Ascii/4) "R98" { var entry = iop_structure.GetEntry(0, (ushort)IOPEntryTag.InteroperabilityIndex); Assert.IsNotNull(entry, "Entry 0x0001 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("R98", (entry as StringIFDEntry).Value); } // Iop.0x0002 (InteroperabilityVersion/Undefined/4) "48 49 48 48" { var entry = iop_structure.GetEntry(0, (ushort)IOPEntryTag.InteroperabilityVersion); Assert.IsNotNull(entry, "Entry 0x0002 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 48, 49, 48, 48 }; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0xA300 (FileSource/Undefined/1) "3" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FileSource); Assert.IsNotNull(entry, "Entry 0xA300 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 3 }; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0xA401 (CustomRendered/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.CustomRendered); Assert.IsNotNull(entry, "Entry 0xA401 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0xA402 (ExposureMode/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureMode); Assert.IsNotNull(entry, "Entry 0xA402 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0xA403 (WhiteBalance/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.WhiteBalance); Assert.IsNotNull(entry, "Entry 0xA403 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0xA404 (DigitalZoomRatio/Rational/1) "100/100" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.DigitalZoomRatio); Assert.IsNotNull(entry, "Entry 0xA404 missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(100, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(100, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0xA406 (SceneCaptureType/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.SceneCaptureType); Assert.IsNotNull(entry, "Entry 0xA406 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0xA407 (GainControl/Short/1) "1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.GainControl); Assert.IsNotNull(entry, "Entry 0xA407 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(1, (entry as ShortIFDEntry).Value); } // Photo.0xA408 (Contrast/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.Contrast); Assert.IsNotNull(entry, "Entry 0xA408 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0xA409 (Saturation/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.Saturation); Assert.IsNotNull(entry, "Entry 0xA409 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0xA40A (Sharpness/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.Sharpness); Assert.IsNotNull(entry, "Entry 0xA40A missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0xEA1D (0xea1d/SLong/1) "34" { // TODO: Unknown IFD tag: Photo / 0xEA1D var entry = exif_structure.GetEntry(0, (ushort)0xEA1D); Assert.IsNotNull(entry, "Entry 0xEA1D missing in IFD 0"); Assert.IsNotNull(entry as SLongIFDEntry, "Entry is not a signed long!"); Assert.AreEqual(34, (entry as SLongIFDEntry).Value); } // Image.0xC4A5 (PrintImageMatching/Undefined/528) "(Value ommitted)" { // TODO: Unknown IFD tag: Image / 0xC4A5 var entry = structure.GetEntry(0, (ushort)0xC4A5); Assert.IsNotNull(entry, "Entry 0xC4A5 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var parsed_hash = Utils.Md5Encode(parsed_bytes); Assert.AreEqual("785d55d75dffafdef5947fb2bfd6c84b", parsed_hash); Assert.AreEqual(528, parsed_bytes.Length); } // Thumbnail.0x0103 (Compression/Short/1) "6" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.Compression); Assert.IsNotNull(entry, "Entry 0x0103 missing in IFD 1"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(6, (entry as ShortIFDEntry).Value); } // Thumbnail.0x011A (XResolution/Rational/1) "1/96" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.XResolution); Assert.IsNotNull(entry, "Entry 0x011A missing in IFD 1"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(96, (entry as RationalIFDEntry).Value.Denominator); } // Thumbnail.0x011B (YResolution/Rational/1) "1/96" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.YResolution); Assert.IsNotNull(entry, "Entry 0x011B missing in IFD 1"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(96, (entry as RationalIFDEntry).Value.Denominator); } // Thumbnail.0x0128 (ResolutionUnit/Short/1) "2" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.ResolutionUnit); Assert.IsNotNull(entry, "Entry 0x0128 missing in IFD 1"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Thumbnail.0x0201 (JPEGInterchangeFormat/ThumbnailDataIFD/1) "3194" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.JPEGInterchangeFormat); Assert.IsNotNull(entry, "Entry 0x0201 missing in IFD 1"); Assert.IsNotNull(entry as ThumbnailDataIFDEntry, "Entry is not a thumbnail IFD!"); } // Thumbnail.0x0202 (JPEGInterchangeFormatLength/Long/1) "5804" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.JPEGInterchangeFormatLength); Assert.IsNotNull(entry, "Entry 0x0202 missing in IFD 1"); Assert.IsNotNull(entry as LongIFDEntry, "Entry is not a long!"); Assert.AreEqual(5804, (entry as LongIFDEntry).Value); } // ---------- End of IFD tests ---------- // ---------- Start of XMP tests ---------- XmpTag xmp = file.GetTag(TagTypes.XMP) as XmpTag; // Xmp.xmp.creatortool (XmpText/46) "Microsoft Windows Photo Gallery 6.0.6000.16386" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.XAP_NS, "creatortool"); Assert.IsNotNull(node); Assert.AreEqual("Microsoft Windows Photo Gallery 6.0.6000.16386", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.tiff.software (XmpText/46) "Microsoft Windows Photo Gallery 6.0.6000.16386" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.TIFF_NS, "software"); Assert.IsNotNull(node); Assert.AreEqual("Microsoft Windows Photo Gallery 6.0.6000.16386", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // ---------- End of XMP tests ---------- }
public void ValidateMetadataInvariants(Image.File file) { Assert.IsNotNull(file); // ---------- Start of IFD tests ---------- var tag = file.GetTag(TagTypes.TiffIFD) as IFDTag; Assert.IsNotNull(tag, "IFD tag not found"); var structure = tag.Structure; // Image.0x010F (Make/Ascii/6) "Canon" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Make); Assert.IsNotNull(entry, "Entry 0x010F missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("Canon", (entry as StringIFDEntry).Value); } // Image.0x0110 (Model/Ascii/23) "Canon EOS 400D DIGITAL" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Model); Assert.IsNotNull(entry, "Entry 0x0110 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("Canon EOS 400D DIGITAL", (entry as StringIFDEntry).Value); } // Image.0x011A (XResolution/Rational/1) "150/1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.XResolution); Assert.IsNotNull(entry, "Entry 0x011A missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(150, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Image.0x011B (YResolution/Rational/1) "150/1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.YResolution); Assert.IsNotNull(entry, "Entry 0x011B missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(150, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Image.0x0128 (ResolutionUnit/Short/1) "2" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.ResolutionUnit); Assert.IsNotNull(entry, "Entry 0x0128 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Image.0x0131 (Software/Ascii/17) "Bibble 5 Pro 5.0" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Software); Assert.IsNotNull(entry, "Entry 0x0131 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("Bibble 5 Pro 5.0", (entry as StringIFDEntry).Value); } // Image.0x8769 (ExifTag/SubIFD/1) "8" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.ExifIFD); Assert.IsNotNull(entry, "Entry 0x8769 missing in IFD 0"); Assert.IsNotNull(entry as SubIFDEntry, "Entry is not a sub IFD!"); } var exif = structure.GetEntry(0, (ushort)IFDEntryTag.ExifIFD) as SubIFDEntry; Assert.IsNotNull(exif, "Exif tag not found"); var exif_structure = exif.Structure; // Photo.0x010F (0x010f/Ascii/6) "Canon" { var entry = exif_structure.GetEntry(0, (ushort)IFDEntryTag.Make); Assert.IsNotNull(entry, "Entry 0x010F missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("Canon", (entry as StringIFDEntry).Value); } // Photo.0x0110 (0x0110/Ascii/23) "Canon EOS 400D DIGITAL" { var entry = exif_structure.GetEntry(0, (ushort)IFDEntryTag.Model); Assert.IsNotNull(entry, "Entry 0x0110 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("Canon EOS 400D DIGITAL", (entry as StringIFDEntry).Value); } // Photo.0x0132 (0x0132/Ascii/20) "2010:02:03 10:51:35" { var entry = exif_structure.GetEntry(0, (ushort)IFDEntryTag.DateTime); Assert.IsNotNull(entry, "Entry 0x0132 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("2010:02:03 10:51:35", (entry as StringIFDEntry).Value); } // Photo.0x829A (ExposureTime/Rational/1) "1/200" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureTime); Assert.IsNotNull(entry, "Entry 0x829A missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(200, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x829D (FNumber/Rational/1) "5/1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FNumber); Assert.IsNotNull(entry, "Entry 0x829D missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(5, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x8822 (ExposureProgram/Short/1) "1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureProgram); Assert.IsNotNull(entry, "Entry 0x8822 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(1, (entry as ShortIFDEntry).Value); } // Photo.0x8827 (ISOSpeedRatings/Short/1) "100" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ISOSpeedRatings); Assert.IsNotNull(entry, "Entry 0x8827 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(100, (entry as ShortIFDEntry).Value); } // Photo.0x9003 (DateTimeOriginal/Ascii/20) "2010:01:06 19:50:44" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.DateTimeOriginal); Assert.IsNotNull(entry, "Entry 0x9003 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("2010:01:06 19:50:44", (entry as StringIFDEntry).Value); } // Photo.0x9004 (DateTimeDigitized/Ascii/20) "2010:01:06 19:50:44" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.DateTimeDigitized); Assert.IsNotNull(entry, "Entry 0x9004 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("2010:01:06 19:50:44", (entry as StringIFDEntry).Value); } // Photo.0x9201 (ShutterSpeedValue/Rational/1) "500948/65536" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ShutterSpeedValue); Assert.IsNotNull(entry, "Entry 0x9201 missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(500948, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(65536, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x9202 (ApertureValue/Rational/1) "304340/65536" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ApertureValue); Assert.IsNotNull(entry, "Entry 0x9202 missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(304340, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(65536, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x9204 (ExposureBiasValue/SRational/1) "0/3" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureBiasValue); Assert.IsNotNull(entry, "Entry 0x9204 missing in IFD 0"); Assert.IsNotNull(entry as SRationalIFDEntry, "Entry is not a srational!"); Assert.AreEqual(0, (entry as SRationalIFDEntry).Value.Numerator); Assert.AreEqual(3, (entry as SRationalIFDEntry).Value.Denominator); } // Photo.0x9205 (MaxApertureValue/Rational/1) "85/32" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.MaxApertureValue); Assert.IsNotNull(entry, "Entry 0x9205 missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(85, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(32, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x9207 (MeteringMode/Short/1) "5" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.MeteringMode); Assert.IsNotNull(entry, "Entry 0x9207 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(5, (entry as ShortIFDEntry).Value); } // Photo.0x9209 (Flash/Short/1) "9" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.Flash); Assert.IsNotNull(entry, "Entry 0x9209 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(9, (entry as ShortIFDEntry).Value); } // Photo.0x920A (FocalLength/Rational/1) "21/1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FocalLength); Assert.IsNotNull(entry, "Entry 0x920A missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(21, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x9290 (SubSecTime/Ascii/4) "976" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.SubsecTime); Assert.IsNotNull(entry, "Entry 0x9290 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("976", (entry as StringIFDEntry).Value); } // Photo.0xA402 (ExposureMode/Short/1) "1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureMode); Assert.IsNotNull(entry, "Entry 0xA402 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(1, (entry as ShortIFDEntry).Value); } // Photo.0xA403 (WhiteBalance/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.WhiteBalance); Assert.IsNotNull(entry, "Entry 0xA403 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0xA406 (SceneCaptureType/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.SceneCaptureType); Assert.IsNotNull(entry, "Entry 0xA406 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // ---------- End of IFD tests ---------- // ---------- Start of XMP tests ---------- XmpTag xmp = file.GetTag(TagTypes.XMP) as XmpTag; // Xmp.tiff.Model (XmpText/22) "Canon EOS 400D DIGITAL" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.TIFF_NS, "Model"); Assert.IsNotNull(node); Assert.AreEqual("Canon EOS 400D DIGITAL", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.tiff.Make (XmpText/5) "Canon" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.TIFF_NS, "Make"); Assert.IsNotNull(node); Assert.AreEqual("Canon", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.tiff.ImageWidth (XmpText/4) "3888" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.TIFF_NS, "ImageWidth"); Assert.IsNotNull(node); Assert.AreEqual("3888", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.tiff.ImageLength (XmpText/4) "2592" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.TIFF_NS, "ImageLength"); Assert.IsNotNull(node); Assert.AreEqual("2592", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.tiff.FNumber (XmpText/5) "50/10" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.TIFF_NS, "FNumber"); Assert.IsNotNull(node); Assert.AreEqual("50/10", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.tiff.XResolution (XmpText/5) "150/1" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.TIFF_NS, "XResolution"); Assert.IsNotNull(node); Assert.AreEqual("150/1", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.tiff.YResolution (XmpText/5) "150/1" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.TIFF_NS, "YResolution"); Assert.IsNotNull(node); Assert.AreEqual("150/1", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.tiff.ResolutionUnit (XmpText/1) "2" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.TIFF_NS, "ResolutionUnit"); Assert.IsNotNull(node); Assert.AreEqual("2", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.exif.ExposureProgram (XmpText/1) "1" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.EXIF_NS, "ExposureProgram"); Assert.IsNotNull(node); Assert.AreEqual("1", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.exif.MeteringMode (XmpText/1) "5" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.EXIF_NS, "MeteringMode"); Assert.IsNotNull(node); Assert.AreEqual("5", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.exif.ExposureMode (XmpText/1) "1" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.EXIF_NS, "ExposureMode"); Assert.IsNotNull(node); Assert.AreEqual("1", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.exif.WhiteBalance (XmpText/1) "0" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.EXIF_NS, "WhiteBalance"); Assert.IsNotNull(node); Assert.AreEqual("0", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.exif.SceneCaptureType (XmpText/1) "0" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.EXIF_NS, "SceneCaptureType"); Assert.IsNotNull(node); Assert.AreEqual("0", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.exif.ISOSpeedRating (XmpText/3) "100" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.EXIF_NS, "ISOSpeedRating"); Assert.IsNotNull(node); Assert.AreEqual("100", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.exif.Flash (XmpText/1) "9" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.EXIF_NS, "Flash"); Assert.IsNotNull(node); Assert.AreEqual("9", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.exif.ApertureValue (XmpText/12) "304340/65536" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.EXIF_NS, "ApertureValue"); Assert.IsNotNull(node); Assert.AreEqual("304340/65536", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.exif.ShutterSpeedValue (XmpText/12) "500948/65536" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.EXIF_NS, "ShutterSpeedValue"); Assert.IsNotNull(node); Assert.AreEqual("500948/65536", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.exif.ExposureTime (XmpText/5) "1/200" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.EXIF_NS, "ExposureTime"); Assert.IsNotNull(node); Assert.AreEqual("1/200", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.exif.ExposureBiasValue (XmpText/3) "0/3" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.EXIF_NS, "ExposureBiasValue"); Assert.IsNotNull(node); Assert.AreEqual("0/3", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.exif.FocalLength (XmpText/4) "21/1" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.EXIF_NS, "FocalLength"); Assert.IsNotNull(node); Assert.AreEqual("21/1", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.photoshop.DateCreated (XmpText/24) "2010-01-06T19:50:44.000Z" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.PHOTOSHOP_NS, "DateCreated"); Assert.IsNotNull(node); Assert.AreEqual("2010-01-06T19:50:44.000Z", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.xmp.Rating (XmpText/1) "0" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.XAP_NS, "Rating"); Assert.IsNotNull(node); Assert.AreEqual("0", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // ---------- End of XMP tests ---------- }
public void ValidateMetadataInvariants(Image.File file) { Assert.IsNotNull(file); var properties = file.Properties; Assert.IsNotNull(properties); Assert.AreEqual(3920, properties.PhotoWidth, "PhotoWidth"); Assert.AreEqual(2638, properties.PhotoHeight, "PhotoHeight"); // ---------- Start of IFD tests ---------- var tag = file.GetTag(TagTypes.TiffIFD) as IFDTag; Assert.IsNotNull(tag, "IFD tag not found"); var structure = tag.Structure; // Image.0x00FE (NewSubfileType/Long/1) "1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.NewSubfileType); Assert.IsNotNull(entry, "Entry 0x00FE missing in IFD 0"); Assert.IsNotNull(entry as LongIFDEntry, "Entry is not a long!"); Assert.AreEqual(1, (entry as LongIFDEntry).Value); } // Image.0x0100 (ImageWidth/Long/1) "320" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.ImageWidth); Assert.IsNotNull(entry, "Entry 0x0100 missing in IFD 0"); Assert.IsNotNull(entry as LongIFDEntry, "Entry is not a long!"); Assert.AreEqual(320, (entry as LongIFDEntry).Value); } // Image.0x0101 (ImageLength/Long/1) "240" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.ImageLength); Assert.IsNotNull(entry, "Entry 0x0101 missing in IFD 0"); Assert.IsNotNull(entry as LongIFDEntry, "Entry is not a long!"); Assert.AreEqual(240, (entry as LongIFDEntry).Value); } // Image.0x0102 (BitsPerSample/Short/3) "8 8 8" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.BitsPerSample); Assert.IsNotNull(entry, "Entry 0x0102 missing in IFD 0"); Assert.IsNotNull(entry as ShortArrayIFDEntry, "Entry is not a short array!"); Assert.AreEqual(new ushort [] { 8, 8, 8 }, (entry as ShortArrayIFDEntry).Values); } // Image.0x0103 (Compression/Short/1) "1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Compression); Assert.IsNotNull(entry, "Entry 0x0103 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(1, (entry as ShortIFDEntry).Value); } // Image.0x0106 (PhotometricInterpretation/Short/1) "2" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.PhotometricInterpretation); Assert.IsNotNull(entry, "Entry 0x0106 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Image.0x010F (Make/Ascii/16) "Leica Camera AG" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Make); Assert.IsNotNull(entry, "Entry 0x010F missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("Leica Camera AG", (entry as StringIFDEntry).Value); } // Image.0x0110 (Model/Ascii/18) "M8 Digital Camera" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Model); Assert.IsNotNull(entry, "Entry 0x0110 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("M8 Digital Camera", (entry as StringIFDEntry).Value); } // Image.0x0111 (StripOffsets/StripOffsets/4) "3936 69216 134496 199776" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.StripOffsets); Assert.IsNotNull(entry, "Entry 0x0111 missing in IFD 0"); Assert.IsNotNull(entry as StripOffsetsIFDEntry, "Entry is not a strip offsets entry!"); Assert.AreEqual(4, (entry as StripOffsetsIFDEntry).Values.Length); } // Image.0x0112 (Orientation/Short/1) "1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Orientation); Assert.IsNotNull(entry, "Entry 0x0112 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(1, (entry as ShortIFDEntry).Value); } // Image.0x0115 (SamplesPerPixel/Short/1) "3" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.SamplesPerPixel); Assert.IsNotNull(entry, "Entry 0x0115 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(3, (entry as ShortIFDEntry).Value); } // Image.0x0116 (RowsPerStrip/Long/1) "68" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.RowsPerStrip); Assert.IsNotNull(entry, "Entry 0x0116 missing in IFD 0"); Assert.IsNotNull(entry as LongIFDEntry, "Entry is not a long!"); Assert.AreEqual(68, (entry as LongIFDEntry).Value); } // Image.0x0117 (StripByteCounts/Long/4) "65280 65280 65280 34560" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.StripByteCounts); Assert.IsNotNull(entry, "Entry 0x0117 missing in IFD 0"); Assert.IsNotNull(entry as LongArrayIFDEntry, "Entry is not a long array!"); Assert.AreEqual(new long [] { 65280, 65280, 65280, 34560 }, (entry as LongArrayIFDEntry).Values); } // Image.0x011A (XResolution/Rational/1) "72/1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.XResolution); Assert.IsNotNull(entry, "Entry 0x011A missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(72, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Image.0x011B (YResolution/Rational/1) "72/1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.YResolution); Assert.IsNotNull(entry, "Entry 0x011B missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(72, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Image.0x011C (PlanarConfiguration/Short/1) "1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.PlanarConfiguration); Assert.IsNotNull(entry, "Entry 0x011C missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(1, (entry as ShortIFDEntry).Value); } // Image.0x0128 (ResolutionUnit/Short/1) "2" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.ResolutionUnit); Assert.IsNotNull(entry, "Entry 0x0128 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Image.0x0131 (Software/Ascii/6) "1.107" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Software); Assert.IsNotNull(entry, "Entry 0x0131 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("1.107", (entry as StringIFDEntry).Value); } // Image.0x013B (Artist/Ascii/1) "" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Artist); Assert.IsNotNull(entry, "Entry 0x013B missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("", (entry as StringIFDEntry).Value.Trim()); } var SubImage1_structure = (structure.GetEntry(0, (ushort)IFDEntryTag.SubIFDs) as SubIFDArrayEntry).Entries [0]; Assert.IsNotNull(SubImage1_structure, "SubImage1 structure not found"); // SubImage1.0x00FE (NewSubfileType/Long/1) "0" { var entry = SubImage1_structure.GetEntry(0, (ushort)IFDEntryTag.NewSubfileType); Assert.IsNotNull(entry, "Entry 0x00FE missing in IFD 0"); Assert.IsNotNull(entry as LongIFDEntry, "Entry is not a long!"); Assert.AreEqual(0, (entry as LongIFDEntry).Value); } // SubImage1.0x0100 (ImageWidth/Long/1) "3920" { var entry = SubImage1_structure.GetEntry(0, (ushort)IFDEntryTag.ImageWidth); Assert.IsNotNull(entry, "Entry 0x0100 missing in IFD 0"); Assert.IsNotNull(entry as LongIFDEntry, "Entry is not a long!"); Assert.AreEqual(3920, (entry as LongIFDEntry).Value); } // SubImage1.0x0101 (ImageLength/Long/1) "2638" { var entry = SubImage1_structure.GetEntry(0, (ushort)IFDEntryTag.ImageLength); Assert.IsNotNull(entry, "Entry 0x0101 missing in IFD 0"); Assert.IsNotNull(entry as LongIFDEntry, "Entry is not a long!"); Assert.AreEqual(2638, (entry as LongIFDEntry).Value); } // SubImage1.0x0102 (BitsPerSample/Short/1) "8" { var entry = SubImage1_structure.GetEntry(0, (ushort)IFDEntryTag.BitsPerSample); Assert.IsNotNull(entry, "Entry 0x0102 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(8, (entry as ShortIFDEntry).Value); } // SubImage1.0x0103 (Compression/Short/1) "1" { var entry = SubImage1_structure.GetEntry(0, (ushort)IFDEntryTag.Compression); Assert.IsNotNull(entry, "Entry 0x0103 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(1, (entry as ShortIFDEntry).Value); } // SubImage1.0x0106 (PhotometricInterpretation/Short/1) "32803" { var entry = SubImage1_structure.GetEntry(0, (ushort)IFDEntryTag.PhotometricInterpretation); Assert.IsNotNull(entry, "Entry 0x0106 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(32803, (entry as ShortIFDEntry).Value); } // SubImage1.0x0111 (StripOffsets/StripOffsets/165) "234336 297056 359776 422496 485216 547936 610656 673376 736096 798816 861536 924256 986976 1049696 1112416 1175136 1237856 1300576 1363296 1426016 1488736 1551456 1614176 1676896 1739616 1802336 1865056 1927776 1990496 2053216 2115936 2178656 2241376 2304096 2366816 2429536 2492256 2554976 2617696 2680416 2743136 2805856 2868576 2931296 2994016 3056736 3119456 3182176 3244896 3307616 3370336 3433056 3495776 3558496 3621216 3683936 3746656 3809376 3872096 3934816 3997536 4060256 4122976 4185696 4248416 4311136 4373856 4436576 4499296 4562016 4624736 4687456 4750176 4812896 4875616 4938336 5001056 5063776 5126496 5189216 5251936 5314656 5377376 5440096 5502816 5565536 5628256 5690976 5753696 5816416 5879136 5941856 6004576 6067296 6130016 6192736 6255456 6318176 6380896 6443616 6506336 6569056 6631776 6694496 6757216 6819936 6882656 6945376 7008096 7070816 7133536 7196256 7258976 7321696 7384416 7447136 7509856 7572576 7635296 7698016 7760736 7823456 7886176 7948896 8011616 8074336 8137056 8199776 8262496 8325216 8387936 8450656 8513376 8576096 8638816 8701536 8764256 8826976 8889696 8952416 9015136 9077856 9140576 9203296 9266016 9328736 9391456 9454176 9516896 9579616 9642336 9705056 9767776 9830496 9893216 9955936 10018656 10081376 10144096 10206816 10269536 10332256 10394976 10457696 10520416" { var entry = SubImage1_structure.GetEntry(0, (ushort)IFDEntryTag.StripOffsets); Assert.IsNotNull(entry, "Entry 0x0111 missing in IFD 0"); Assert.IsNotNull(entry as StripOffsetsIFDEntry, "Entry is not a strip offsets entry!"); Assert.AreEqual(165, (entry as StripOffsetsIFDEntry).Values.Length); } // SubImage1.0x0115 (SamplesPerPixel/Short/1) "1" { var entry = SubImage1_structure.GetEntry(0, (ushort)IFDEntryTag.SamplesPerPixel); Assert.IsNotNull(entry, "Entry 0x0115 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(1, (entry as ShortIFDEntry).Value); } // SubImage1.0x0116 (RowsPerStrip/Long/1) "16" { var entry = SubImage1_structure.GetEntry(0, (ushort)IFDEntryTag.RowsPerStrip); Assert.IsNotNull(entry, "Entry 0x0116 missing in IFD 0"); Assert.IsNotNull(entry as LongIFDEntry, "Entry is not a long!"); Assert.AreEqual(16, (entry as LongIFDEntry).Value); } // SubImage1.0x0117 (StripByteCounts/Long/165) "62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 62720 54880" { var entry = SubImage1_structure.GetEntry(0, (ushort)IFDEntryTag.StripByteCounts); Assert.IsNotNull(entry, "Entry 0x0117 missing in IFD 0"); Assert.IsNotNull(entry as LongArrayIFDEntry, "Entry is not a long array!"); Assert.AreEqual(new long [] { 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 62720, 54880 }, (entry as LongArrayIFDEntry).Values); } // SubImage1.0x011A (XResolution/Rational/1) "300/1" { var entry = SubImage1_structure.GetEntry(0, (ushort)IFDEntryTag.XResolution); Assert.IsNotNull(entry, "Entry 0x011A missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(300, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // SubImage1.0x011B (YResolution/Rational/1) "300/1" { var entry = SubImage1_structure.GetEntry(0, (ushort)IFDEntryTag.YResolution); Assert.IsNotNull(entry, "Entry 0x011B missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(300, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // SubImage1.0x011C (PlanarConfiguration/Short/1) "1" { var entry = SubImage1_structure.GetEntry(0, (ushort)IFDEntryTag.PlanarConfiguration); Assert.IsNotNull(entry, "Entry 0x011C missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(1, (entry as ShortIFDEntry).Value); } // SubImage1.0x0128 (ResolutionUnit/Short/1) "2" { var entry = SubImage1_structure.GetEntry(0, (ushort)IFDEntryTag.ResolutionUnit); Assert.IsNotNull(entry, "Entry 0x0128 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // SubImage1.0x828D (CFARepeatPatternDim/Short/2) "2 2" { // TODO: Unknown IFD tag: SubImage1 / 0x828D var entry = SubImage1_structure.GetEntry(0, (ushort)0x828D); Assert.IsNotNull(entry, "Entry 0x828D missing in IFD 0"); Assert.IsNotNull(entry as ShortArrayIFDEntry, "Entry is not a short array!"); Assert.AreEqual(new ushort [] { 2, 2 }, (entry as ShortArrayIFDEntry).Values); } // SubImage1.0x828E (CFAPattern/Byte/4) "0 1 1 2" { // TODO: Unknown IFD tag: SubImage1 / 0x828E var entry = SubImage1_structure.GetEntry(0, (ushort)0x828E); Assert.IsNotNull(entry, "Entry 0x828E missing in IFD 0"); Assert.IsNotNull(entry as ByteVectorIFDEntry, "Entry is not a byte array!"); var parsed_bytes = (entry as ByteVectorIFDEntry).Data.Data; var bytes = new byte [] { 0, 1, 1, 2 }; Assert.AreEqual(bytes, parsed_bytes); } // SubImage1.0xC618 (LinearizationTable/Short/256) "0 0 1 2 4 6 9 12 16 20 25 30 36 42 49 56 64 72 81 90 100 110 121 132 144 156 169 182 196 210 225 240 256 272 289 306 324 342 361 380 400 420 441 462 484 506 529 552 576 600 625 650 676 702 729 756 784 812 841 870 900 930 961 992 1024 1056 1089 1122 1156 1190 1225 1260 1296 1332 1369 1406 1444 1482 1521 1560 1600 1640 1681 1722 1764 1806 1849 1892 1936 1980 2025 2070 2116 2162 2209 2256 2304 2352 2401 2450 2500 2550 2601 2652 2704 2756 2809 2862 2916 2970 3025 3080 3136 3192 3249 3306 3364 3422 3481 3540 3600 3660 3721 3782 3844 3906 3969 4032 4096 4160 4225 4290 4356 4422 4489 4556 4624 4692 4761 4830 4900 4970 5041 5112 5184 5256 5329 5402 5476 5550 5625 5700 5776 5852 5929 6006 6084 6162 6241 6320 6400 6480 6561 6642 6724 6806 6889 6972 7056 7140 7225 7310 7396 7482 7569 7656 7744 7832 7921 8010 8100 8190 8281 8372 8464 8556 8649 8742 8836 8930 9025 9120 9216 9312 9409 9506 9604 9702 9801 9900 10000 10100 10201 10302 10404 10506 10609 10712 10816 10920 11025 11130 11236 11342 11449 11556 11664 11772 11881 11990 12100 12210 12321 12432 12544 12656 12769 12882 12996 13110 13225 13340 13456 13572 13689 13806 13924 14042 14161 14280 14400 14520 14641 14762 14884 15006 15129 15252 15376 15500 15625 15750 15876 16002 16129 16256" { var entry = SubImage1_structure.GetEntry(0, (ushort)IFDEntryTag.LinearizationTable); Assert.IsNotNull(entry, "Entry 0xC618 missing in IFD 0"); Assert.IsNotNull(entry as ShortArrayIFDEntry, "Entry is not a short array!"); Assert.AreEqual(new ushort [] { 0, 0, 1, 2, 4, 6, 9, 12, 16, 20, 25, 30, 36, 42, 49, 56, 64, 72, 81, 90, 100, 110, 121, 132, 144, 156, 169, 182, 196, 210, 225, 240, 256, 272, 289, 306, 324, 342, 361, 380, 400, 420, 441, 462, 484, 506, 529, 552, 576, 600, 625, 650, 676, 702, 729, 756, 784, 812, 841, 870, 900, 930, 961, 992, 1024, 1056, 1089, 1122, 1156, 1190, 1225, 1260, 1296, 1332, 1369, 1406, 1444, 1482, 1521, 1560, 1600, 1640, 1681, 1722, 1764, 1806, 1849, 1892, 1936, 1980, 2025, 2070, 2116, 2162, 2209, 2256, 2304, 2352, 2401, 2450, 2500, 2550, 2601, 2652, 2704, 2756, 2809, 2862, 2916, 2970, 3025, 3080, 3136, 3192, 3249, 3306, 3364, 3422, 3481, 3540, 3600, 3660, 3721, 3782, 3844, 3906, 3969, 4032, 4096, 4160, 4225, 4290, 4356, 4422, 4489, 4556, 4624, 4692, 4761, 4830, 4900, 4970, 5041, 5112, 5184, 5256, 5329, 5402, 5476, 5550, 5625, 5700, 5776, 5852, 5929, 6006, 6084, 6162, 6241, 6320, 6400, 6480, 6561, 6642, 6724, 6806, 6889, 6972, 7056, 7140, 7225, 7310, 7396, 7482, 7569, 7656, 7744, 7832, 7921, 8010, 8100, 8190, 8281, 8372, 8464, 8556, 8649, 8742, 8836, 8930, 9025, 9120, 9216, 9312, 9409, 9506, 9604, 9702, 9801, 9900, 10000, 10100, 10201, 10302, 10404, 10506, 10609, 10712, 10816, 10920, 11025, 11130, 11236, 11342, 11449, 11556, 11664, 11772, 11881, 11990, 12100, 12210, 12321, 12432, 12544, 12656, 12769, 12882, 12996, 13110, 13225, 13340, 13456, 13572, 13689, 13806, 13924, 14042, 14161, 14280, 14400, 14520, 14641, 14762, 14884, 15006, 15129, 15252, 15376, 15500, 15625, 15750, 15876, 16002, 16129, 16256 }, (entry as ShortArrayIFDEntry).Values); } // SubImage1.0xC61D (WhiteLevel/Long/1) "16383" { var entry = SubImage1_structure.GetEntry(0, (ushort)IFDEntryTag.WhiteLevel); Assert.IsNotNull(entry, "Entry 0xC61D missing in IFD 0"); Assert.IsNotNull(entry as LongIFDEntry, "Entry is not a long!"); Assert.AreEqual(16383, (entry as LongIFDEntry).Value); } // SubImage1.0xC61F (DefaultCropOrigin/Short/2) "2 2" { var entry = SubImage1_structure.GetEntry(0, (ushort)IFDEntryTag.DefaultCropOrigin); Assert.IsNotNull(entry, "Entry 0xC61F missing in IFD 0"); Assert.IsNotNull(entry as ShortArrayIFDEntry, "Entry is not a short array!"); Assert.AreEqual(new ushort [] { 2, 2 }, (entry as ShortArrayIFDEntry).Values); } // SubImage1.0xC620 (DefaultCropSize/Short/2) "3916 2634" { var entry = SubImage1_structure.GetEntry(0, (ushort)IFDEntryTag.DefaultCropSize); Assert.IsNotNull(entry, "Entry 0xC620 missing in IFD 0"); Assert.IsNotNull(entry as ShortArrayIFDEntry, "Entry is not a short array!"); Assert.AreEqual(new ushort [] { 3916, 2634 }, (entry as ShortArrayIFDEntry).Values); } // SubImage1.0xC62D (BayerGreenSplit/Long/1) "500" { var entry = SubImage1_structure.GetEntry(0, (ushort)IFDEntryTag.BayerGreenSplit); Assert.IsNotNull(entry, "Entry 0xC62D missing in IFD 0"); Assert.IsNotNull(entry as LongIFDEntry, "Entry is not a long!"); Assert.AreEqual(500, (entry as LongIFDEntry).Value); } // SubImage1.0xC632 (AntiAliasStrength/Rational/1) "0/1" { var entry = SubImage1_structure.GetEntry(0, (ushort)IFDEntryTag.AntiAliasStrength); Assert.IsNotNull(entry, "Entry 0xC632 missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(0, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Image.0x8298 (Copyright/Ascii/1) "" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Copyright); Assert.IsNotNull(entry, "Entry 0x8298 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("", (entry as StringIFDEntry).Value.Trim()); } // Image.0x8769 (ExifTag/SubIFD/1) "764" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.ExifIFD); Assert.IsNotNull(entry, "Entry 0x8769 missing in IFD 0"); Assert.IsNotNull(entry as SubIFDEntry, "Entry is not a sub IFD!"); } var exif = structure.GetEntry(0, (ushort)IFDEntryTag.ExifIFD) as SubIFDEntry; Assert.IsNotNull(exif, "Exif tag not found"); var exif_structure = exif.Structure; // Photo.0x829A (ExposureTime/Rational/1) "12000000/1000000" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureTime); Assert.IsNotNull(entry, "Entry 0x829A missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(12000000, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1000000, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x8822 (ExposureProgram/Short/1) "1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureProgram); Assert.IsNotNull(entry, "Entry 0x8822 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(1, (entry as ShortIFDEntry).Value); } // Photo.0x8827 (ISOSpeedRatings/Short/1) "160" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ISOSpeedRatings); Assert.IsNotNull(entry, "Entry 0x8827 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(160, (entry as ShortIFDEntry).Value); } // Photo.0x9000 (ExifVersion/Undefined/4) "48 50 50 48" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExifVersion); Assert.IsNotNull(entry, "Entry 0x9000 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 48, 50, 50, 48 }; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0x9004 (DateTimeDigitized/Ascii/20) "2007:08:02 22:13:49" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.DateTimeDigitized); Assert.IsNotNull(entry, "Entry 0x9004 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("2007:08:02 22:13:49", (entry as StringIFDEntry).Value); } // Photo.0x9201 (ShutterSpeedValue/SRational/1) "-229376/65536" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ShutterSpeedValue); Assert.IsNotNull(entry, "Entry 0x9201 missing in IFD 0"); Assert.IsNotNull(entry as SRationalIFDEntry, "Entry is not a srational!"); Assert.AreEqual(-229376, (entry as SRationalIFDEntry).Value.Numerator); Assert.AreEqual(65536, (entry as SRationalIFDEntry).Value.Denominator); } // Photo.0x9204 (ExposureBiasValue/SRational/1) "0/65536" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureBiasValue); Assert.IsNotNull(entry, "Entry 0x9204 missing in IFD 0"); Assert.IsNotNull(entry as SRationalIFDEntry, "Entry is not a srational!"); Assert.AreEqual(0, (entry as SRationalIFDEntry).Value.Numerator); Assert.AreEqual(65536, (entry as SRationalIFDEntry).Value.Denominator); } // Photo.0x9205 (MaxApertureValue/Rational/1) "131072/65536" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.MaxApertureValue); Assert.IsNotNull(entry, "Entry 0x9205 missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(131072, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(65536, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x9207 (MeteringMode/Short/1) "2" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.MeteringMode); Assert.IsNotNull(entry, "Entry 0x9207 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Photo.0x9208 (LightSource/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.LightSource); Assert.IsNotNull(entry, "Entry 0x9208 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0x9209 (Flash/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.Flash); Assert.IsNotNull(entry, "Entry 0x9209 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0x920A (FocalLength/Rational/1) "50000/1000" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FocalLength); Assert.IsNotNull(entry, "Entry 0x920A missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(50000, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1000, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x927C (MakerNote/MakerNote/220) "" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.MakerNote); Assert.IsNotNull(entry, "Entry 0x927C missing in IFD 0"); Assert.IsNotNull(entry as MakernoteIFDEntry, "Entry is not a makernote IFD!"); } // Photo.0xA300 (FileSource/Undefined/1) "3" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FileSource); Assert.IsNotNull(entry, "Entry 0xA300 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 3 }; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0xA301 (SceneType/Undefined/1) "1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.SceneType); Assert.IsNotNull(entry, "Entry 0xA301 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 1 }; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0xA403 (WhiteBalance/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.WhiteBalance); Assert.IsNotNull(entry, "Entry 0xA403 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0xA404 (DigitalZoomRatio/Rational/1) "0/1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.DigitalZoomRatio); Assert.IsNotNull(entry, "Entry 0xA404 missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(0, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0xA405 (FocalLengthIn35mmFilm/Short/1) "67" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FocalLengthIn35mmFilm); Assert.IsNotNull(entry, "Entry 0xA405 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(67, (entry as ShortIFDEntry).Value); } // Photo.0xA406 (SceneCaptureType/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.SceneCaptureType); Assert.IsNotNull(entry, "Entry 0xA406 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0xA420 (ImageUniqueID/Ascii/33) "00000000000000000000000000000147" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ImageUniqueID); Assert.IsNotNull(entry, "Entry 0xA420 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("00000000000000000000000000000147", (entry as StringIFDEntry).Value); } // Image.0x882B (SelfTimerMode/Short/1) "0" { // TODO: Unknown IFD tag: Image / 0x882B var entry = structure.GetEntry(0, (ushort)0x882B); Assert.IsNotNull(entry, "Entry 0x882B missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Image.0x9003 (DateTimeOriginal/Ascii/20) "2007:08:02 22:13:49" { var entry = structure.GetEntry(0, (ushort)ExifEntryTag.DateTimeOriginal); Assert.IsNotNull(entry, "Entry 0x9003 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("2007:08:02 22:13:49", (entry as StringIFDEntry).Value); } // Image.0x920E (FocalPlaneXResolution/Rational/1) "3729/1" { // TODO: Unknown IFD tag: Image / 0x920E var entry = structure.GetEntry(0, (ushort)0x920E); Assert.IsNotNull(entry, "Entry 0x920E missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(3729, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Image.0x920F (FocalPlaneYResolution/Rational/1) "3764/1" { // TODO: Unknown IFD tag: Image / 0x920F var entry = structure.GetEntry(0, (ushort)0x920F); Assert.IsNotNull(entry, "Entry 0x920F missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(3764, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Image.0x9210 (FocalPlaneResolutionUnit/Short/1) "2" { // TODO: Unknown IFD tag: Image / 0x9210 var entry = structure.GetEntry(0, (ushort)0x9210); Assert.IsNotNull(entry, "Entry 0x9210 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Image.0x9216 (TIFFEPStandardID/Byte/4) "0 0 0 1" { // TODO: Unknown IFD tag: Image / 0x9216 var entry = structure.GetEntry(0, (ushort)0x9216); Assert.IsNotNull(entry, "Entry 0x9216 missing in IFD 0"); Assert.IsNotNull(entry as ByteVectorIFDEntry, "Entry is not a byte array!"); var parsed_bytes = (entry as ByteVectorIFDEntry).Data.Data; var bytes = new byte [] { 0, 0, 0, 1 }; Assert.AreEqual(bytes, parsed_bytes); } // Image.0xC612 (DNGVersion/Byte/4) "1 0 0 0" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.DNGVersion); Assert.IsNotNull(entry, "Entry 0xC612 missing in IFD 0"); Assert.IsNotNull(entry as ByteVectorIFDEntry, "Entry is not a byte array!"); var parsed_bytes = (entry as ByteVectorIFDEntry).Data.Data; var bytes = new byte [] { 1, 0, 0, 0 }; Assert.AreEqual(bytes, parsed_bytes); } // Image.0xC614 (UniqueCameraModel/Ascii/18) "M8 Digital Camera" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.UniqueCameraModel); Assert.IsNotNull(entry, "Entry 0xC614 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("M8 Digital Camera", (entry as StringIFDEntry).Value); } // Image.0xC621 (ColorMatrix1/SRational/9) "10469/10000 -5314/10000 1280/10000 -4326/10000 12176/10000 2419/10000 -886/10000 2473/10000 7160/10000" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.ColorMatrix1); Assert.IsNotNull(entry, "Entry 0xC621 missing in IFD 0"); Assert.IsNotNull(entry as SRationalArrayIFDEntry, "Entry is not a srational array!"); var parts = (entry as SRationalArrayIFDEntry).Values; Assert.AreEqual(9, parts.Length); Assert.AreEqual(10469, parts[0].Numerator); Assert.AreEqual(10000, parts[0].Denominator); Assert.AreEqual(-5314, parts[1].Numerator); Assert.AreEqual(10000, parts[1].Denominator); Assert.AreEqual(1280, parts[2].Numerator); Assert.AreEqual(10000, parts[2].Denominator); Assert.AreEqual(-4326, parts[3].Numerator); Assert.AreEqual(10000, parts[3].Denominator); Assert.AreEqual(12176, parts[4].Numerator); Assert.AreEqual(10000, parts[4].Denominator); Assert.AreEqual(2419, parts[5].Numerator); Assert.AreEqual(10000, parts[5].Denominator); Assert.AreEqual(-886, parts[6].Numerator); Assert.AreEqual(10000, parts[6].Denominator); Assert.AreEqual(2473, parts[7].Numerator); Assert.AreEqual(10000, parts[7].Denominator); Assert.AreEqual(7160, parts[8].Numerator); Assert.AreEqual(10000, parts[8].Denominator); } // Image.0xC622 (ColorMatrix2/SRational/9) "7675/10000 -2195/10000 -305/10000 -5860/10000 14118/10000 1857/10000 -2425/10000 4007/10000 6578/10000" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.ColorMatrix2); Assert.IsNotNull(entry, "Entry 0xC622 missing in IFD 0"); Assert.IsNotNull(entry as SRationalArrayIFDEntry, "Entry is not a srational array!"); var parts = (entry as SRationalArrayIFDEntry).Values; Assert.AreEqual(9, parts.Length); Assert.AreEqual(7675, parts[0].Numerator); Assert.AreEqual(10000, parts[0].Denominator); Assert.AreEqual(-2195, parts[1].Numerator); Assert.AreEqual(10000, parts[1].Denominator); Assert.AreEqual(-305, parts[2].Numerator); Assert.AreEqual(10000, parts[2].Denominator); Assert.AreEqual(-5860, parts[3].Numerator); Assert.AreEqual(10000, parts[3].Denominator); Assert.AreEqual(14118, parts[4].Numerator); Assert.AreEqual(10000, parts[4].Denominator); Assert.AreEqual(1857, parts[5].Numerator); Assert.AreEqual(10000, parts[5].Denominator); Assert.AreEqual(-2425, parts[6].Numerator); Assert.AreEqual(10000, parts[6].Denominator); Assert.AreEqual(4007, parts[7].Numerator); Assert.AreEqual(10000, parts[7].Denominator); Assert.AreEqual(6578, parts[8].Numerator); Assert.AreEqual(10000, parts[8].Denominator); } // Image.0xC623 (CameraCalibration1/SRational/9) "1/1 0/1 0/1 0/1 1/1 0/1 0/1 0/1 1/1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.CameraCalibration1); Assert.IsNotNull(entry, "Entry 0xC623 missing in IFD 0"); Assert.IsNotNull(entry as SRationalArrayIFDEntry, "Entry is not a srational array!"); var parts = (entry as SRationalArrayIFDEntry).Values; Assert.AreEqual(9, parts.Length); Assert.AreEqual(1, parts[0].Numerator); Assert.AreEqual(1, parts[0].Denominator); Assert.AreEqual(0, parts[1].Numerator); Assert.AreEqual(1, parts[1].Denominator); Assert.AreEqual(0, parts[2].Numerator); Assert.AreEqual(1, parts[2].Denominator); Assert.AreEqual(0, parts[3].Numerator); Assert.AreEqual(1, parts[3].Denominator); Assert.AreEqual(1, parts[4].Numerator); Assert.AreEqual(1, parts[4].Denominator); Assert.AreEqual(0, parts[5].Numerator); Assert.AreEqual(1, parts[5].Denominator); Assert.AreEqual(0, parts[6].Numerator); Assert.AreEqual(1, parts[6].Denominator); Assert.AreEqual(0, parts[7].Numerator); Assert.AreEqual(1, parts[7].Denominator); Assert.AreEqual(1, parts[8].Numerator); Assert.AreEqual(1, parts[8].Denominator); } // Image.0xC624 (CameraCalibration2/SRational/9) "1/1 0/1 0/1 0/1 1/1 0/1 0/1 0/1 1/1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.CameraCalibration2); Assert.IsNotNull(entry, "Entry 0xC624 missing in IFD 0"); Assert.IsNotNull(entry as SRationalArrayIFDEntry, "Entry is not a srational array!"); var parts = (entry as SRationalArrayIFDEntry).Values; Assert.AreEqual(9, parts.Length); Assert.AreEqual(1, parts[0].Numerator); Assert.AreEqual(1, parts[0].Denominator); Assert.AreEqual(0, parts[1].Numerator); Assert.AreEqual(1, parts[1].Denominator); Assert.AreEqual(0, parts[2].Numerator); Assert.AreEqual(1, parts[2].Denominator); Assert.AreEqual(0, parts[3].Numerator); Assert.AreEqual(1, parts[3].Denominator); Assert.AreEqual(1, parts[4].Numerator); Assert.AreEqual(1, parts[4].Denominator); Assert.AreEqual(0, parts[5].Numerator); Assert.AreEqual(1, parts[5].Denominator); Assert.AreEqual(0, parts[6].Numerator); Assert.AreEqual(1, parts[6].Denominator); Assert.AreEqual(0, parts[7].Numerator); Assert.AreEqual(1, parts[7].Denominator); Assert.AreEqual(1, parts[8].Numerator); Assert.AreEqual(1, parts[8].Denominator); } // Image.0xC628 (AsShotNeutral/Rational/3) "16384/34488 16384/16384 16384/20567" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.AsShotNeutral); Assert.IsNotNull(entry, "Entry 0xC628 missing in IFD 0"); Assert.IsNotNull(entry as RationalArrayIFDEntry, "Entry is not a rational array!"); var parts = (entry as RationalArrayIFDEntry).Values; Assert.AreEqual(3, parts.Length); Assert.AreEqual(16384, parts[0].Numerator); Assert.AreEqual(34488, parts[0].Denominator); Assert.AreEqual(16384, parts[1].Numerator); Assert.AreEqual(16384, parts[1].Denominator); Assert.AreEqual(16384, parts[2].Numerator); Assert.AreEqual(20567, parts[2].Denominator); } // Image.0xC62B (BaselineNoise/Rational/1) "1/1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.BaselineNoise); Assert.IsNotNull(entry, "Entry 0xC62B missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Image.0xC62C (BaselineSharpness/Rational/1) "1/1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.BaselineSharpness); Assert.IsNotNull(entry, "Entry 0xC62C missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Image.0xC62F (CameraSerialNumber/Ascii/8) "3106091" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.CameraSerialNumber); Assert.IsNotNull(entry, "Entry 0xC62F missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("3106091", (entry as StringIFDEntry).Value); } // Image.0xC65A (CalibrationIlluminant1/Short/1) "17" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.CalibrationIlluminant1); Assert.IsNotNull(entry, "Entry 0xC65A missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(17, (entry as ShortIFDEntry).Value); } // Image.0xC65B (CalibrationIlluminant2/Short/1) "21" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.CalibrationIlluminant2); Assert.IsNotNull(entry, "Entry 0xC65B missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(21, (entry as ShortIFDEntry).Value); } // ---------- End of IFD tests ---------- }
public void ValidateMetadataInvariants(Image.File file) { Assert.IsNotNull(file); // ---------- Start of IFD tests ---------- var tag = file.GetTag(TagTypes.TiffIFD) as IFDTag; Assert.IsNotNull(tag, "IFD tag not found"); var structure = tag.Structure; // Image.0x010E (ImageDescription/Ascii/15) "Communications" // --> Test removed because of CommentModificationValidator, value is checked there. // Image.0x010F (Make/Ascii/9) "FUJIFILM" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Make); Assert.IsNotNull(entry, "Entry 0x010F missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("FUJIFILM", (entry as StringIFDEntry).Value); } // Image.0x0110 (Model/Ascii/13) "FinePixS1Pro" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Model); Assert.IsNotNull(entry, "Entry 0x0110 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("FinePixS1Pro", (entry as StringIFDEntry).Value); } // Image.0x0112 (Orientation/Short/1) "1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Orientation); Assert.IsNotNull(entry, "Entry 0x0112 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(1, (entry as ShortIFDEntry).Value); } // Image.0x011A (XResolution/Rational/1) "300/1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.XResolution); Assert.IsNotNull(entry, "Entry 0x011A missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(300, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Image.0x011B (YResolution/Rational/1) "300/1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.YResolution); Assert.IsNotNull(entry, "Entry 0x011B missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(300, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Image.0x0128 (ResolutionUnit/Short/1) "2" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.ResolutionUnit); Assert.IsNotNull(entry, "Entry 0x0128 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Image.0x0131 (Software/Ascii/20) "Adobe Photoshop 7.0" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Software); Assert.IsNotNull(entry, "Entry 0x0131 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("Adobe Photoshop 7.0", (entry as StringIFDEntry).Value); } // Image.0x0132 (DateTime/Ascii/20) "2002:07:19 13:28:10" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.DateTime); Assert.IsNotNull(entry, "Entry 0x0132 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("2002:07:19 13:28:10", (entry as StringIFDEntry).Value); } // Image.0x013B (Artist/Ascii/12) "Ian Britton" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Artist); Assert.IsNotNull(entry, "Entry 0x013B missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("Ian Britton", (entry as StringIFDEntry).Value); } // Image.0x0213 (YCbCrPositioning/Short/1) "2" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.YCbCrPositioning); Assert.IsNotNull(entry, "Entry 0x0213 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Image.0x0214 (ReferenceBlackWhite/Rational/6) "0/1 255/1 128/1 255/1 128/1 255/1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.ReferenceBlackWhite); Assert.IsNotNull(entry, "Entry 0x0214 missing in IFD 0"); Assert.IsNotNull(entry as RationalArrayIFDEntry, "Entry is not a rational array!"); var parts = (entry as RationalArrayIFDEntry).Values; Assert.AreEqual(6, parts.Length); Assert.AreEqual(0, parts[0].Numerator); Assert.AreEqual(1, parts[0].Denominator); Assert.AreEqual(255, parts[1].Numerator); Assert.AreEqual(1, parts[1].Denominator); Assert.AreEqual(128, parts[2].Numerator); Assert.AreEqual(1, parts[2].Denominator); Assert.AreEqual(255, parts[3].Numerator); Assert.AreEqual(1, parts[3].Denominator); Assert.AreEqual(128, parts[4].Numerator); Assert.AreEqual(1, parts[4].Denominator); Assert.AreEqual(255, parts[5].Numerator); Assert.AreEqual(1, parts[5].Denominator); } // Image.0x8298 (Copyright/Ascii/27) "ian Britton - FreeFoto.com" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Copyright); Assert.IsNotNull(entry, "Entry 0x8298 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("ian Britton - FreeFoto.com", (entry as StringIFDEntry).Value); } // Image.0x8769 (ExifTag/SubIFD/1) "376" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.ExifIFD); Assert.IsNotNull(entry, "Entry 0x8769 missing in IFD 0"); Assert.IsNotNull(entry as SubIFDEntry, "Entry is not a sub IFD!"); } var exif = structure.GetEntry(0, (ushort)IFDEntryTag.ExifIFD) as SubIFDEntry; Assert.IsNotNull(exif, "Exif tag not found"); var exif_structure = exif.Structure; // Photo.0x829D (FNumber/Rational/1) "1074135040/1677721600" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FNumber); Assert.IsNotNull(entry, "Entry 0x829D missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(1074135040, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1677721600, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x8822 (ExposureProgram/Short/1) "4" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureProgram); Assert.IsNotNull(entry, "Entry 0x8822 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(4, (entry as ShortIFDEntry).Value); } // Photo.0x8827 (ISOSpeedRatings/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ISOSpeedRatings); Assert.IsNotNull(entry, "Entry 0x8827 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0x9000 (ExifVersion/Undefined/4) "48 50 48 48 " { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExifVersion); Assert.IsNotNull(entry, "Entry 0x9000 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var bytes = new byte [] { 48, 50, 48, 48 }; var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0x9003 (DateTimeOriginal/Ascii/20) "2002:07:13 15:58:28" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.DateTimeOriginal); Assert.IsNotNull(entry, "Entry 0x9003 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("2002:07:13 15:58:28", (entry as StringIFDEntry).Value); } // Photo.0x9004 (DateTimeDigitized/Ascii/20) "2002:07:13 15:58:28" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.DateTimeDigitized); Assert.IsNotNull(entry, "Entry 0x9004 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("2002:07:13 15:58:28", (entry as StringIFDEntry).Value); } // Photo.0x9101 (ComponentsConfiguration/Undefined/4) "1 2 3 0 " { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ComponentsConfiguration); Assert.IsNotNull(entry, "Entry 0x9101 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var bytes = new byte [] { 1, 2, 3, 0 }; var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0x9201 (ShutterSpeedValue/SRational/1) "1275068416/134217728" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ShutterSpeedValue); Assert.IsNotNull(entry, "Entry 0x9201 missing in IFD 0"); Assert.IsNotNull(entry as SRationalIFDEntry, "Entry is not a srational!"); Assert.AreEqual(1275068416, (entry as SRationalIFDEntry).Value.Numerator); Assert.AreEqual(134217728, (entry as SRationalIFDEntry).Value.Denominator); } // Photo.0x9202 (ApertureValue/Rational/1) "1610612736/201326592" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ApertureValue); Assert.IsNotNull(entry, "Entry 0x9202 missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(1610612736, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(201326592, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x9203 (BrightnessValue/SRational/1) "436469760/1677721600" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.BrightnessValue); Assert.IsNotNull(entry, "Entry 0x9203 missing in IFD 0"); Assert.IsNotNull(entry as SRationalIFDEntry, "Entry is not a srational!"); Assert.AreEqual(436469760, (entry as SRationalIFDEntry).Value.Numerator); Assert.AreEqual(1677721600, (entry as SRationalIFDEntry).Value.Denominator); } // Photo.0x9204 (ExposureBiasValue/SRational/1) "-1090519041/1677721600" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureBiasValue); Assert.IsNotNull(entry, "Entry 0x9204 missing in IFD 0"); Assert.IsNotNull(entry as SRationalIFDEntry, "Entry is not a srational!"); Assert.AreEqual(-1090519041, (entry as SRationalIFDEntry).Value.Numerator); Assert.AreEqual(1677721600, (entry as SRationalIFDEntry).Value.Denominator); } // Photo.0x9207 (MeteringMode/Short/1) "5" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.MeteringMode); Assert.IsNotNull(entry, "Entry 0x9207 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(5, (entry as ShortIFDEntry).Value); } // Photo.0x9209 (Flash/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.Flash); Assert.IsNotNull(entry, "Entry 0x9209 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0x920A (FocalLength/Rational/1) "0/16777216" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FocalLength); Assert.IsNotNull(entry, "Entry 0x920A missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(0, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(16777216, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0xA000 (FlashpixVersion/Undefined/4) "48 49 48 48 " { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FlashpixVersion); Assert.IsNotNull(entry, "Entry 0xA000 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var bytes = new byte [] { 48, 49, 48, 48 }; var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0xA001 (ColorSpace/Short/1) "1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ColorSpace); Assert.IsNotNull(entry, "Entry 0xA001 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(1, (entry as ShortIFDEntry).Value); } // Photo.0xA002 (PixelXDimension/Long/1) "2400" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.PixelXDimension); Assert.IsNotNull(entry, "Entry 0xA002 missing in IFD 0"); Assert.IsNotNull(entry as LongIFDEntry, "Entry is not a long!"); Assert.AreEqual(2400, (entry as LongIFDEntry).Value); } // Photo.0xA003 (PixelYDimension/Long/1) "1600" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.PixelYDimension); Assert.IsNotNull(entry, "Entry 0xA003 missing in IFD 0"); Assert.IsNotNull(entry as LongIFDEntry, "Entry is not a long!"); Assert.AreEqual(1600, (entry as LongIFDEntry).Value); } // Photo.0xA20E (FocalPlaneXResolution/Rational/1) "202178560/16777216" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FocalPlaneXResolution); Assert.IsNotNull(entry, "Entry 0xA20E missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(202178560, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(16777216, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0xA20F (FocalPlaneYResolution/Rational/1) "202178560/16777216" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FocalPlaneYResolution); Assert.IsNotNull(entry, "Entry 0xA20F missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(202178560, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(16777216, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0xA210 (FocalPlaneResolutionUnit/Short/1) "2" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FocalPlaneResolutionUnit); Assert.IsNotNull(entry, "Entry 0xA210 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Photo.0xA217 (SensingMethod/Short/1) "2" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.SensingMethod); Assert.IsNotNull(entry, "Entry 0xA217 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Photo.0xA300 (FileSource/Undefined/1) "0 " { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FileSource); Assert.IsNotNull(entry, "Entry 0xA300 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var bytes = new byte [] { 0 }; var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0xA301 (SceneType/Undefined/1) "0 " { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.SceneType); Assert.IsNotNull(entry, "Entry 0xA301 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var bytes = new byte [] { 0 }; var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; Assert.AreEqual(bytes, parsed_bytes); } // Image.0x8825 (GPSTag/SubIFD/1) "776" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.GPSIFD); Assert.IsNotNull(entry, "Entry 0x8825 missing in IFD 0"); Assert.IsNotNull(entry as SubIFDEntry, "Entry is not a sub IFD!"); } var gps = structure.GetEntry(0, (ushort)IFDEntryTag.GPSIFD) as SubIFDEntry; Assert.IsNotNull(gps, "GPS tag not found"); var gps_structure = gps.Structure; // GPSInfo.0x0000 (GPSVersionID/Byte/4) "2 0 0 0 " { var entry = gps_structure.GetEntry(0, (ushort)GPSEntryTag.GPSVersionID); Assert.IsNotNull(entry, "Entry 0x0000 missing in IFD 0"); Assert.IsNotNull(entry as ByteVectorIFDEntry, "Entry is not a byte array!"); var bytes = new byte [] { 2, 0, 0, 0 }; var parsed_bytes = (entry as ByteVectorIFDEntry).Data.Data; Assert.AreEqual(bytes, parsed_bytes); } // GPSInfo.0x0001 (GPSLatitudeRef/Ascii/2) "N" { var entry = gps_structure.GetEntry(0, (ushort)GPSEntryTag.GPSLatitudeRef); Assert.IsNotNull(entry, "Entry 0x0001 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("N", (entry as StringIFDEntry).Value); } // GPSInfo.0x0002 (GPSLatitude/Rational/3) "54/1 5938/100 0/1" { var entry = gps_structure.GetEntry(0, (ushort)GPSEntryTag.GPSLatitude); Assert.IsNotNull(entry, "Entry 0x0002 missing in IFD 0"); Assert.IsNotNull(entry as RationalArrayIFDEntry, "Entry is not a rational array!"); var parts = (entry as RationalArrayIFDEntry).Values; Assert.AreEqual(3, parts.Length); Assert.AreEqual(54, parts[0].Numerator); Assert.AreEqual(1, parts[0].Denominator); Assert.AreEqual(5938, parts[1].Numerator); Assert.AreEqual(100, parts[1].Denominator); Assert.AreEqual(0, parts[2].Numerator); Assert.AreEqual(1, parts[2].Denominator); } // GPSInfo.0x0003 (GPSLongitudeRef/Ascii/2) "W" { var entry = gps_structure.GetEntry(0, (ushort)GPSEntryTag.GPSLongitudeRef); Assert.IsNotNull(entry, "Entry 0x0003 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("W", (entry as StringIFDEntry).Value); } // GPSInfo.0x0004 (GPSLongitude/Rational/3) "1/1 5485/100 0/1" { var entry = gps_structure.GetEntry(0, (ushort)GPSEntryTag.GPSLongitude); Assert.IsNotNull(entry, "Entry 0x0004 missing in IFD 0"); Assert.IsNotNull(entry as RationalArrayIFDEntry, "Entry is not a rational array!"); var parts = (entry as RationalArrayIFDEntry).Values; Assert.AreEqual(3, parts.Length); Assert.AreEqual(1, parts[0].Numerator); Assert.AreEqual(1, parts[0].Denominator); Assert.AreEqual(5485, parts[1].Numerator); Assert.AreEqual(100, parts[1].Denominator); Assert.AreEqual(0, parts[2].Numerator); Assert.AreEqual(1, parts[2].Denominator); } // GPSInfo.0x0007 (GPSTimeStamp/Rational/3) "14/1 58/1 24/1" { var entry = gps_structure.GetEntry(0, (ushort)GPSEntryTag.GPSTimeStamp); Assert.IsNotNull(entry, "Entry 0x0007 missing in IFD 0"); Assert.IsNotNull(entry as RationalArrayIFDEntry, "Entry is not a rational array!"); var parts = (entry as RationalArrayIFDEntry).Values; Assert.AreEqual(3, parts.Length); Assert.AreEqual(14, parts[0].Numerator); Assert.AreEqual(1, parts[0].Denominator); Assert.AreEqual(58, parts[1].Numerator); Assert.AreEqual(1, parts[1].Denominator); Assert.AreEqual(24, parts[2].Numerator); Assert.AreEqual(1, parts[2].Denominator); } // GPSInfo.0x0012 (GPSMapDatum/Ascii/6) "WGS84" { var entry = gps_structure.GetEntry(0, (ushort)GPSEntryTag.GPSMapDatum); Assert.IsNotNull(entry, "Entry 0x0012 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("WGS84", (entry as StringIFDEntry).Value); } // Thumbnail.0x0103 (Compression/Short/1) "6" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.Compression); Assert.IsNotNull(entry, "Entry 0x0103 missing in IFD 1"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(6, (entry as ShortIFDEntry).Value); } // Thumbnail.0x011A (XResolution/Rational/1) "72/1" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.XResolution); Assert.IsNotNull(entry, "Entry 0x011A missing in IFD 1"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(72, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Thumbnail.0x011B (YResolution/Rational/1) "72/1" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.YResolution); Assert.IsNotNull(entry, "Entry 0x011B missing in IFD 1"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(72, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Thumbnail.0x0128 (ResolutionUnit/Short/1) "2" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.ResolutionUnit); Assert.IsNotNull(entry, "Entry 0x0128 missing in IFD 1"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Thumbnail.0x0201 (JPEGInterchangeFormat/ThumbnailDataIFD/1) "1038" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.JPEGInterchangeFormat); Assert.IsNotNull(entry, "Entry 0x0201 missing in IFD 1"); Assert.IsNotNull(entry as ThumbnailDataIFDEntry, "Entry is not a thumbnail IFD!"); } // Thumbnail.0x0202 (JPEGInterchangeFormatLength/Long/1) "3662" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.JPEGInterchangeFormatLength); Assert.IsNotNull(entry, "Entry 0x0202 missing in IFD 1"); Assert.IsNotNull(entry as LongIFDEntry, "Entry is not a long!"); Assert.AreEqual(3662, (entry as LongIFDEntry).Value); } // ---------- End of IFD tests ---------- // ---------- Start of XMP tests ---------- XmpTag xmp = file.GetTag(TagTypes.XMP) as XmpTag; // Xmp.photoshop.CaptionWriter (XmpText/11) "Ian Britton" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.PHOTOSHOP_NS, "CaptionWriter"); Assert.IsNotNull(node); Assert.AreEqual("Ian Britton", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.photoshop.Headline (XmpText/14) "Communications" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.PHOTOSHOP_NS, "Headline"); Assert.IsNotNull(node); Assert.AreEqual("Communications", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.photoshop.AuthorsPosition (XmpText/12) "Photographer" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.PHOTOSHOP_NS, "AuthorsPosition"); Assert.IsNotNull(node); Assert.AreEqual("Photographer", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.photoshop.Credit (XmpText/11) "Ian Britton" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.PHOTOSHOP_NS, "Credit"); Assert.IsNotNull(node); Assert.AreEqual("Ian Britton", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.photoshop.Source (XmpText/12) "FreeFoto.com" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.PHOTOSHOP_NS, "Source"); Assert.IsNotNull(node); Assert.AreEqual("FreeFoto.com", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.photoshop.City (XmpText/1) "" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.PHOTOSHOP_NS, "City"); Assert.IsNotNull(node); Assert.AreEqual("", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.photoshop.State (XmpText/1) "" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.PHOTOSHOP_NS, "State"); Assert.IsNotNull(node); Assert.AreEqual("", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.photoshop.Country (XmpText/14) "Ubited Kingdom" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.PHOTOSHOP_NS, "Country"); Assert.IsNotNull(node); Assert.AreEqual("Ubited Kingdom", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.photoshop.Category (XmpText/3) "BUS" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.PHOTOSHOP_NS, "Category"); Assert.IsNotNull(node); Assert.AreEqual("BUS", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.photoshop.DateCreated (XmpText/10) "2002-06-20" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.PHOTOSHOP_NS, "DateCreated"); Assert.IsNotNull(node); Assert.AreEqual("2002-06-20", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.photoshop.Urgency (XmpText/1) "5" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.PHOTOSHOP_NS, "Urgency"); Assert.IsNotNull(node); Assert.AreEqual("5", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.photoshop.SupplementalCategories (XmpBag/1) "Communications" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.PHOTOSHOP_NS, "SupplementalCategories"); Assert.IsNotNull(node); Assert.AreEqual(XmpNodeType.Bag, node.Type); Assert.AreEqual("", node.Value); Assert.AreEqual(1, node.Children.Count); Assert.AreEqual("Communications", node.Children [0].Value); } // Xmp.xmpBJ.JobRef (XmpText/0) "type="Bag"" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.XAP_BJ_NS, "JobRef"); Assert.IsNotNull(node); Assert.AreEqual(XmpNodeType.Bag, node.Type); } // Xmp.xmpBJ.JobRef[1] (XmpText/0) "type="Struct"" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.XAP_BJ_NS, "JobRef"); Assert.IsNotNull(node); node = node.Children [0]; Assert.IsNotNull(node); Assert.AreEqual(XmpNodeType.Struct, node.Type); } // Xmp.xmpBJ.JobRef[1]/stJob:name (XmpText/12) "Photographer" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.XAP_BJ_NS, "JobRef"); Assert.IsNotNull(node); node = node.Children [0]; Assert.IsNotNull(node); node = node.GetChild(XmpTag.JOB_NS, "name"); Assert.IsNotNull(node); Assert.AreEqual("Photographer", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.xmpMM.DocumentID (XmpText/58) "adobe:docid:photoshop:84d4dba8-9b11-11d6-895d-c4d063a70fb0" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.XAP_MM_NS, "DocumentID"); Assert.IsNotNull(node); Assert.AreEqual("adobe:docid:photoshop:84d4dba8-9b11-11d6-895d-c4d063a70fb0", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.xmpRights.WebStatement (XmpText/16) "www.freefoto.com" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.XAP_RIGHTS_NS, "WebStatement"); Assert.IsNotNull(node); Assert.AreEqual("www.freefoto.com", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.xmpRights.Marked (XmpText/4) "True" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.XAP_RIGHTS_NS, "Marked"); Assert.IsNotNull(node); Assert.AreEqual("True", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); } // Xmp.dc.description (LangAlt/1) "lang="x-default" Communications" // --> Test removed because of CommentModificationValidator, value is checked there. // Xmp.dc.creator (XmpSeq/1) "Ian Britton" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.DC_NS, "creator"); Assert.IsNotNull(node); Assert.AreEqual(XmpNodeType.Seq, node.Type); Assert.AreEqual("", node.Value); Assert.AreEqual(1, node.Children.Count); Assert.AreEqual("Ian Britton", node.Children [0].Value); } // Xmp.dc.title (LangAlt/1) "lang="x-default" Communications" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.DC_NS, "title"); Assert.IsNotNull(node); Assert.AreEqual("x-default", node.Children [0].GetQualifier(XmpTag.XML_NS, "lang").Value); Assert.AreEqual("Communications", node.Children [0].Value); } // Xmp.dc.rights (LangAlt/1) "lang="x-default" ian Britton - FreeFoto.com" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.DC_NS, "rights"); Assert.IsNotNull(node); Assert.AreEqual("x-default", node.Children [0].GetQualifier(XmpTag.XML_NS, "lang").Value); Assert.AreEqual("ian Britton - FreeFoto.com", node.Children [0].Value); } // Xmp.dc.subject (XmpBag/1) "Communications" // --> Test removed because of KeywordsModificationValidator, value is checked there. // ---------- End of XMP tests ---------- }
public void ValidateMetadataInvariants(Image.File file) { Assert.IsNotNull(file); // ---------- Start of IFD tests ---------- var tag = file.GetTag(TagTypes.TiffIFD) as IFDTag; Assert.IsNotNull(tag, "IFD tag not found"); var structure = tag.Structure; // Image.0x010F (Make/Ascii/18) "NIKON CORPORATION" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Make); Assert.IsNotNull(entry, "Entry 0x010F missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("NIKON CORPORATION", (entry as StringIFDEntry).Value); } // Image.0x0110 (Model/Ascii/11) "NIKON D70s" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Model); Assert.IsNotNull(entry, "Entry 0x0110 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("NIKON D70s", (entry as StringIFDEntry).Value); } // Image.0x011A (XResolution/Rational/1) "150/1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.XResolution); Assert.IsNotNull(entry, "Entry 0x011A missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(150, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Image.0x011B (YResolution/Rational/1) "150/1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.YResolution); Assert.IsNotNull(entry, "Entry 0x011B missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(150, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Image.0x0128 (ResolutionUnit/Short/1) "2" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.ResolutionUnit); Assert.IsNotNull(entry, "Entry 0x0128 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Image.0x0131 (Software/Ascii/17) "Bibble 5 Pro 5.0" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Software); Assert.IsNotNull(entry, "Entry 0x0131 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("Bibble 5 Pro 5.0", (entry as StringIFDEntry).Value); } // Image.0x8769 (ExifTag/SubIFD/1) "8" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.ExifIFD); Assert.IsNotNull(entry, "Entry 0x8769 missing in IFD 0"); Assert.IsNotNull(entry as SubIFDEntry, "Entry is not a sub IFD!"); } var exif = structure.GetEntry(0, (ushort)IFDEntryTag.ExifIFD) as SubIFDEntry; Assert.IsNotNull(exif, "Exif tag not found"); var exif_structure = exif.Structure; // Photo.0x010F (0x010f/Ascii/18) "NIKON CORPORATION" { var entry = exif_structure.GetEntry(0, (ushort)IFDEntryTag.Make); Assert.IsNotNull(entry, "Entry 0x010F missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("NIKON CORPORATION", (entry as StringIFDEntry).Value); } // Photo.0x0110 (0x0110/Ascii/11) "NIKON D70s" { var entry = exif_structure.GetEntry(0, (ushort)IFDEntryTag.Model); Assert.IsNotNull(entry, "Entry 0x0110 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("NIKON D70s", (entry as StringIFDEntry).Value); } // Photo.0x0132 (0x0132/Ascii/20) "2010:02:03 11:02:18" { var entry = exif_structure.GetEntry(0, (ushort)IFDEntryTag.DateTime); Assert.IsNotNull(entry, "Entry 0x0132 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("2010:02:03 11:02:18", (entry as StringIFDEntry).Value); } // Photo.0x829A (ExposureTime/Rational/1) "10/7500" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureTime); Assert.IsNotNull(entry, "Entry 0x829A missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(10, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(7500, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x829D (FNumber/Rational/1) "13/1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FNumber); Assert.IsNotNull(entry, "Entry 0x829D missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(13, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x8822 (ExposureProgram/Short/1) "2" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureProgram); Assert.IsNotNull(entry, "Entry 0x8822 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Photo.0x8827 (ISOSpeedRatings/Short/1) "1600" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ISOSpeedRatings); Assert.IsNotNull(entry, "Entry 0x8827 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(1600, (entry as ShortIFDEntry).Value); } // Photo.0x9003 (DateTimeOriginal/Ascii/20) "2007:02:15 17:07:48" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.DateTimeOriginal); Assert.IsNotNull(entry, "Entry 0x9003 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("2007:02:15 17:07:48", (entry as StringIFDEntry).Value); } // Photo.0x9004 (DateTimeDigitized/Ascii/20) "2007:02:15 17:07:48" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.DateTimeDigitized); Assert.IsNotNull(entry, "Entry 0x9004 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("2007:02:15 17:07:48", (entry as StringIFDEntry).Value); } // Photo.0x9204 (ExposureBiasValue/SRational/1) "0/6" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureBiasValue); Assert.IsNotNull(entry, "Entry 0x9204 missing in IFD 0"); Assert.IsNotNull(entry as SRationalIFDEntry, "Entry is not a srational!"); Assert.AreEqual(0, (entry as SRationalIFDEntry).Value.Numerator); Assert.AreEqual(6, (entry as SRationalIFDEntry).Value.Denominator); } // Photo.0x9205 (MaxApertureValue/Rational/1) "50/10" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.MaxApertureValue); Assert.IsNotNull(entry, "Entry 0x9205 missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(50, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(10, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x9207 (MeteringMode/Short/1) "5" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.MeteringMode); Assert.IsNotNull(entry, "Entry 0x9207 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(5, (entry as ShortIFDEntry).Value); } // Photo.0x9208 (LightSource/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.LightSource); Assert.IsNotNull(entry, "Entry 0x9208 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0x920A (FocalLength/Rational/1) "50/1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FocalLength); Assert.IsNotNull(entry, "Entry 0x920A missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(50, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x9290 (SubSecTime/Ascii/4) "889" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.SubsecTime); Assert.IsNotNull(entry, "Entry 0x9290 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("889", (entry as StringIFDEntry).Value); } // Photo.0x9291 (SubSecTimeOriginal/Ascii/4) "800" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.SubsecTimeOriginal); Assert.IsNotNull(entry, "Entry 0x9291 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("800", (entry as StringIFDEntry).Value); } // Photo.0x9292 (SubSecTimeDigitized/Ascii/4) "800" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.SubsecTimeDigitized); Assert.IsNotNull(entry, "Entry 0x9292 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("800", (entry as StringIFDEntry).Value); } // Photo.0xA402 (ExposureMode/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureMode); Assert.IsNotNull(entry, "Entry 0xA402 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0xA403 (WhiteBalance/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.WhiteBalance); Assert.IsNotNull(entry, "Entry 0xA403 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0xA405 (FocalLengthIn35mmFilm/Short/1) "75" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FocalLengthIn35mmFilm); Assert.IsNotNull(entry, "Entry 0xA405 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(75, (entry as ShortIFDEntry).Value); } // Photo.0xA406 (SceneCaptureType/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.SceneCaptureType); Assert.IsNotNull(entry, "Entry 0xA406 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0xA408 (Contrast/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.Contrast); Assert.IsNotNull(entry, "Entry 0xA408 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0xA409 (Saturation/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.Saturation); Assert.IsNotNull(entry, "Entry 0xA409 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0xA40A (Sharpness/Short/1) "1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.Sharpness); Assert.IsNotNull(entry, "Entry 0xA40A missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(1, (entry as ShortIFDEntry).Value); } // Photo.0xA40C (SubjectDistanceRange/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.SubjectDistanceRange); Assert.IsNotNull(entry, "Entry 0xA40C missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // ---------- End of IFD tests ---------- // ---------- Start of XMP tests ---------- XmpTag xmp = file.GetTag(TagTypes.XMP) as XmpTag; // Xmp.tiff.Model (XmpText/10) "NIKON D70s" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.TIFF_NS, "Model"); Assert.IsNotNull(node); Assert.AreEqual("NIKON D70s", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.tiff.Make (XmpText/17) "NIKON CORPORATION" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.TIFF_NS, "Make"); Assert.IsNotNull(node); Assert.AreEqual("NIKON CORPORATION", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.tiff.ImageWidth (XmpText/4) "3024" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.TIFF_NS, "ImageWidth"); Assert.IsNotNull(node); Assert.AreEqual("3024", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.tiff.ImageLength (XmpText/4) "1998" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.TIFF_NS, "ImageLength"); Assert.IsNotNull(node); Assert.AreEqual("1998", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.tiff.FNumber (XmpText/6) "130/10" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.TIFF_NS, "FNumber"); Assert.IsNotNull(node); Assert.AreEqual("130/10", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.tiff.XResolution (XmpText/5) "150/1" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.TIFF_NS, "XResolution"); Assert.IsNotNull(node); Assert.AreEqual("150/1", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.tiff.YResolution (XmpText/5) "150/1" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.TIFF_NS, "YResolution"); Assert.IsNotNull(node); Assert.AreEqual("150/1", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.tiff.ResolutionUnit (XmpText/1) "2" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.TIFF_NS, "ResolutionUnit"); Assert.IsNotNull(node); Assert.AreEqual("2", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.exif.ExposureProgram (XmpText/1) "2" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.EXIF_NS, "ExposureProgram"); Assert.IsNotNull(node); Assert.AreEqual("2", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.exif.MeteringMode (XmpText/1) "5" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.EXIF_NS, "MeteringMode"); Assert.IsNotNull(node); Assert.AreEqual("5", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.exif.LightSource (XmpText/1) "0" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.EXIF_NS, "LightSource"); Assert.IsNotNull(node); Assert.AreEqual("0", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.exif.ExposureMode (XmpText/1) "0" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.EXIF_NS, "ExposureMode"); Assert.IsNotNull(node); Assert.AreEqual("0", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.exif.WhiteBalance (XmpText/1) "0" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.EXIF_NS, "WhiteBalance"); Assert.IsNotNull(node); Assert.AreEqual("0", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.exif.FocalLengthIn35mmFilm (XmpText/2) "75" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.EXIF_NS, "FocalLengthIn35mmFilm"); Assert.IsNotNull(node); Assert.AreEqual("75", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.exif.SceneCaptureType (XmpText/1) "0" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.EXIF_NS, "SceneCaptureType"); Assert.IsNotNull(node); Assert.AreEqual("0", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.exif.Contrast (XmpText/1) "0" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.EXIF_NS, "Contrast"); Assert.IsNotNull(node); Assert.AreEqual("0", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.exif.Saturation (XmpText/1) "0" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.EXIF_NS, "Saturation"); Assert.IsNotNull(node); Assert.AreEqual("0", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.exif.Sharpness (XmpText/1) "1" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.EXIF_NS, "Sharpness"); Assert.IsNotNull(node); Assert.AreEqual("1", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.exif.SubjectDistanceRange (XmpText/1) "0" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.EXIF_NS, "SubjectDistanceRange"); Assert.IsNotNull(node); Assert.AreEqual("0", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.exif.ISOSpeedRating (XmpText/4) "1600" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.EXIF_NS, "ISOSpeedRating"); Assert.IsNotNull(node); Assert.AreEqual("1600", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.exif.MaxApertureValue (XmpText/5) "50/10" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.EXIF_NS, "MaxApertureValue"); Assert.IsNotNull(node); Assert.AreEqual("50/10", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.exif.ExposureTime (XmpText/7) "10/7500" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.EXIF_NS, "ExposureTime"); Assert.IsNotNull(node); Assert.AreEqual("10/7500", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.exif.ExposureBiasValue (XmpText/3) "0/6" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.EXIF_NS, "ExposureBiasValue"); Assert.IsNotNull(node); Assert.AreEqual("0/6", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.exif.FocalLength (XmpText/6) "500/10" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.EXIF_NS, "FocalLength"); Assert.IsNotNull(node); Assert.AreEqual("500/10", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.photoshop.DateCreated (XmpText/24) "2007-02-15T17:07:48.800Z" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.PHOTOSHOP_NS, "DateCreated"); Assert.IsNotNull(node); Assert.AreEqual("2007-02-15T17:07:48.800Z", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // Xmp.xmp.Rating (XmpText/1) "0" { var node = xmp.NodeTree; node = node.GetChild(XmpTag.XAP_NS, "Rating"); Assert.IsNotNull(node); Assert.AreEqual("0", node.Value); Assert.AreEqual(XmpNodeType.Simple, node.Type); Assert.AreEqual(0, node.Children.Count); } // ---------- End of XMP tests ---------- }
public void ValidateMetadataInvariants(Image.File file) { Assert.IsNotNull(file); // ---------- Start of IFD tests ---------- var tag = file.GetTag(TagTypes.TiffIFD) as IFDTag; Assert.IsNotNull(tag, "IFD tag not found"); var structure = tag.Structure; // Image.0x010F (Make/Ascii/16) "Hewlett-Packard" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Make); Assert.IsNotNull(entry, "Entry 0x010F missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("Hewlett-Packard", (entry as StringIFDEntry).Value); } // Image.0x0110 (Model/Ascii/28) "HP PhotoSmart C812 (V09.26)" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Model); Assert.IsNotNull(entry, "Entry 0x0110 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("HP PhotoSmart C812 (V09.26)", (entry as StringIFDEntry).Value); } // Image.0x0112 (Orientation/Short/1) "0" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Orientation); Assert.IsNotNull(entry, "Entry 0x0112 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Image.0x011A (XResolution/Rational/1) "72/1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.XResolution); Assert.IsNotNull(entry, "Entry 0x011A missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(72, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Image.0x011B (YResolution/Rational/1) "72/1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.YResolution); Assert.IsNotNull(entry, "Entry 0x011B missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(72, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Image.0x0128 (ResolutionUnit/Short/1) "2" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.ResolutionUnit); Assert.IsNotNull(entry, "Entry 0x0128 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Image.0x0213 (YCbCrPositioning/Short/1) "1" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.YCbCrPositioning); Assert.IsNotNull(entry, "Entry 0x0213 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(1, (entry as ShortIFDEntry).Value); } // Image.0x8769 (ExifTag/SubIFD/1) "2984" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.ExifIFD); Assert.IsNotNull(entry, "Entry 0x8769 missing in IFD 0"); Assert.IsNotNull(entry as SubIFDEntry, "Entry is not a sub IFD!"); } var exif = structure.GetEntry(0, (ushort)IFDEntryTag.ExifIFD) as SubIFDEntry; Assert.IsNotNull(exif, "Exif tag not found"); var exif_structure = exif.Structure; // Photo.0x829A (ExposureTime/Rational/1) "1666/100000" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureTime); Assert.IsNotNull(entry, "Entry 0x829A missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(1666, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(100000, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x829D (FNumber/Rational/1) "260/100" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FNumber); Assert.IsNotNull(entry, "Entry 0x829D missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(260, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(100, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x8827 (ISOSpeedRatings/Short/1) "200" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ISOSpeedRatings); Assert.IsNotNull(entry, "Entry 0x8827 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(200, (entry as ShortIFDEntry).Value); } // Photo.0x9000 (ExifVersion/Undefined/4) "48 50 49 48" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExifVersion); Assert.IsNotNull(entry, "Entry 0x9000 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 48, 50, 49, 48 }; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0x9003 (DateTimeOriginal/Ascii/20) "2002:01:02 05:00:30" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.DateTimeOriginal); Assert.IsNotNull(entry, "Entry 0x9003 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("2002:01:02 05:00:30", (entry as StringIFDEntry).Value); } // Photo.0x9004 (DateTimeDigitized/Ascii/20) "2002:01:02 05:00:30" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.DateTimeDigitized); Assert.IsNotNull(entry, "Entry 0x9004 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("2002:01:02 05:00:30", (entry as StringIFDEntry).Value); } // Photo.0x9101 (ComponentsConfiguration/Undefined/4) "1 2 3 0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ComponentsConfiguration); Assert.IsNotNull(entry, "Entry 0x9101 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 1, 2, 3, 0 }; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0x9203 (BrightnessValue/SRational/1) "-567/100" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.BrightnessValue); Assert.IsNotNull(entry, "Entry 0x9203 missing in IFD 0"); Assert.IsNotNull(entry as SRationalIFDEntry, "Entry is not a srational!"); Assert.AreEqual(-567, (entry as SRationalIFDEntry).Value.Numerator); Assert.AreEqual(100, (entry as SRationalIFDEntry).Value.Denominator); } // Photo.0x9206 (SubjectDistance/Rational/1) "11691/1000" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.SubjectDistance); Assert.IsNotNull(entry, "Entry 0x9206 missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(11691, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1000, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x9208 (LightSource/Short/1) "4" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.LightSource); Assert.IsNotNull(entry, "Entry 0x9208 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(4, (entry as ShortIFDEntry).Value); } // Photo.0x9209 (Flash/Short/1) "1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.Flash); Assert.IsNotNull(entry, "Entry 0x9209 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(1, (entry as ShortIFDEntry).Value); } // Photo.0x920A (FocalLength/Rational/1) "760/100" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FocalLength); Assert.IsNotNull(entry, "Entry 0x920A missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(760, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(100, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0xA000 (FlashpixVersion/Undefined/4) "48 49 48 48" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FlashpixVersion); Assert.IsNotNull(entry, "Entry 0xA000 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 48, 49, 48, 48 }; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0xA001 (ColorSpace/Short/1) "1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ColorSpace); Assert.IsNotNull(entry, "Entry 0xA001 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(1, (entry as ShortIFDEntry).Value); } // Photo.0xA002 (PixelXDimension/Long/1) "2272" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.PixelXDimension); Assert.IsNotNull(entry, "Entry 0xA002 missing in IFD 0"); Assert.IsNotNull(entry as LongIFDEntry, "Entry is not a long!"); Assert.AreEqual(2272, (entry as LongIFDEntry).Value); } // Photo.0xA003 (PixelYDimension/Long/1) "1712" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.PixelYDimension); Assert.IsNotNull(entry, "Entry 0xA003 missing in IFD 0"); Assert.IsNotNull(entry as LongIFDEntry, "Entry is not a long!"); Assert.AreEqual(1712, (entry as LongIFDEntry).Value); } // Photo.0xA005 (InteroperabilityTag/SubIFD/1) "3378" { var entry = exif_structure.GetEntry(0, (ushort)IFDEntryTag.InteroperabilityIFD); Assert.IsNotNull(entry, "Entry 0xA005 missing in IFD 0"); Assert.IsNotNull(entry as SubIFDEntry, "Entry is not a sub IFD!"); } var iop = exif_structure.GetEntry(0, (ushort)IFDEntryTag.InteroperabilityIFD) as SubIFDEntry; Assert.IsNotNull(iop, "Iop tag not found"); var iop_structure = iop.Structure; // Iop.0x0001 (InteroperabilityIndex/Ascii/4) "R98" { var entry = iop_structure.GetEntry(0, (ushort)IOPEntryTag.InteroperabilityIndex); Assert.IsNotNull(entry, "Entry 0x0001 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("R98", (entry as StringIFDEntry).Value); } // Iop.0x0002 (InteroperabilityVersion/Undefined/4) "48 49 48 48" { var entry = iop_structure.GetEntry(0, (ushort)IOPEntryTag.InteroperabilityVersion); Assert.IsNotNull(entry, "Entry 0x0002 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 48, 49, 48, 48 }; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0xA20B (FlashEnergy/Rational/1) "1000/1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FlashEnergy); Assert.IsNotNull(entry, "Entry 0xA20B missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(1000, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Image.0x92D6 (0x92d6/Undefined/0) "" { // TODO: Unknown IFD tag: Image / 0x92D6 var entry = structure.GetEntry(0, (ushort)0x92D6); Assert.IsNotNull(entry, "Entry 0x92D6 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { }; Assert.AreEqual(bytes, parsed_bytes); } // Thumbnail.0x0103 (Compression/Short/1) "6" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.Compression); Assert.IsNotNull(entry, "Entry 0x0103 missing in IFD 1"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(6, (entry as ShortIFDEntry).Value); } // Thumbnail.0x011A (XResolution/Rational/1) "72/1" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.XResolution); Assert.IsNotNull(entry, "Entry 0x011A missing in IFD 1"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(72, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Thumbnail.0x011B (YResolution/Rational/1) "72/1" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.YResolution); Assert.IsNotNull(entry, "Entry 0x011B missing in IFD 1"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(72, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Thumbnail.0x0128 (ResolutionUnit/Short/1) "2" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.ResolutionUnit); Assert.IsNotNull(entry, "Entry 0x0128 missing in IFD 1"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Thumbnail.0x0201 (JPEGInterchangeFormat/ThumbnailDataIFD/1) "3826" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.JPEGInterchangeFormat); Assert.IsNotNull(entry, "Entry 0x0201 missing in IFD 1"); Assert.IsNotNull(entry as ThumbnailDataIFDEntry, "Entry is not a thumbnail IFD!"); } // Thumbnail.0x0202 (JPEGInterchangeFormatLength/Long/1) "7591" { var entry = structure.GetEntry(1, (ushort)IFDEntryTag.JPEGInterchangeFormatLength); Assert.IsNotNull(entry, "Entry 0x0202 missing in IFD 1"); Assert.IsNotNull(entry as LongIFDEntry, "Entry is not a long!"); Assert.AreEqual(7591, (entry as LongIFDEntry).Value); } // ---------- End of IFD tests ---------- }
public void ValidateMetadataInvariants(Image.File file) { Assert.IsNotNull(file); // ---------- Start of IFD tests ---------- var tag = file.GetTag(TagTypes.TiffIFD) as IFDTag; Assert.IsNotNull(tag, "IFD tag not found"); var structure = tag.Structure; // Image.0x010F (Make/Ascii/10) "Panasonic" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Make); Assert.IsNotNull(entry, "Entry 0x010F missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("Panasonic", (entry as StringIFDEntry).Value); } // Image.0x0110 (Model/Ascii/8) "DMC-TZ5" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Model); Assert.IsNotNull(entry, "Entry 0x0110 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("DMC-TZ5", (entry as StringIFDEntry).Value); } // Image.0x0131 (Software/Ascii/28) "Adobe Photoshop CS4 Windows" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.Software); Assert.IsNotNull(entry, "Entry 0x0131 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("Adobe Photoshop CS4 Windows", (entry as StringIFDEntry).Value); } // Image.0x0132 (DateTime/Ascii/20) "2010:05:03 19:39:29" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.DateTime); Assert.IsNotNull(entry, "Entry 0x0132 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("2010:05:03 19:39:29", (entry as StringIFDEntry).Value); } // Image.0x8769 (ExifTag/SubIFD/1) "152" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.ExifIFD); Assert.IsNotNull(entry, "Entry 0x8769 missing in IFD 0"); Assert.IsNotNull(entry as SubIFDEntry, "Entry is not a sub IFD!"); } var exif = structure.GetEntry(0, (ushort)IFDEntryTag.ExifIFD) as SubIFDEntry; Assert.IsNotNull(exif, "Exif tag not found"); var exif_structure = exif.Structure; // Photo.0x829A (ExposureTime/Rational/1) "10/3200" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureTime); Assert.IsNotNull(entry, "Entry 0x829A missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(10, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(3200, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x829D (FNumber/Rational/1) "49/10" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FNumber); Assert.IsNotNull(entry, "Entry 0x829D missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(49, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(10, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x8822 (ExposureProgram/Short/1) "2" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureProgram); Assert.IsNotNull(entry, "Entry 0x8822 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Photo.0x8827 (ISOSpeedRatings/Short/1) "100" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ISOSpeedRatings); Assert.IsNotNull(entry, "Entry 0x8827 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(100, (entry as ShortIFDEntry).Value); } // Photo.0x9000 (ExifVersion/Undefined/4) "48 50 50 49" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExifVersion); Assert.IsNotNull(entry, "Entry 0x9000 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 48, 50, 50, 49 }; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0x9003 (DateTimeOriginal/Ascii/20) "2009:11:06 12:42:03" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.DateTimeOriginal); Assert.IsNotNull(entry, "Entry 0x9003 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("2009:11:06 12:42:03", (entry as StringIFDEntry).Value); } // Photo.0x9004 (DateTimeDigitized/Ascii/20) "2009:11:06 12:42:03" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.DateTimeDigitized); Assert.IsNotNull(entry, "Entry 0x9004 missing in IFD 0"); Assert.IsNotNull(entry as StringIFDEntry, "Entry is not a string!"); Assert.AreEqual("2009:11:06 12:42:03", (entry as StringIFDEntry).Value); } // Photo.0x9101 (ComponentsConfiguration/Undefined/4) "1 2 3 0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ComponentsConfiguration); Assert.IsNotNull(entry, "Entry 0x9101 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 1, 2, 3, 0 }; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0x9102 (CompressedBitsPerPixel/Rational/1) "4/1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.CompressedBitsPerPixel); Assert.IsNotNull(entry, "Entry 0x9102 missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(4, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(1, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x9204 (ExposureBiasValue/SRational/1) "0/100" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureBiasValue); Assert.IsNotNull(entry, "Entry 0x9204 missing in IFD 0"); Assert.IsNotNull(entry as SRationalIFDEntry, "Entry is not a srational!"); Assert.AreEqual(0, (entry as SRationalIFDEntry).Value.Numerator); Assert.AreEqual(100, (entry as SRationalIFDEntry).Value.Denominator); } // Photo.0x9205 (MaxApertureValue/Rational/1) "344/100" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.MaxApertureValue); Assert.IsNotNull(entry, "Entry 0x9205 missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(344, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(100, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0x9207 (MeteringMode/Short/1) "5" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.MeteringMode); Assert.IsNotNull(entry, "Entry 0x9207 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(5, (entry as ShortIFDEntry).Value); } // Photo.0x9208 (LightSource/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.LightSource); Assert.IsNotNull(entry, "Entry 0x9208 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0x9209 (Flash/Short/1) "16" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.Flash); Assert.IsNotNull(entry, "Entry 0x9209 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(16, (entry as ShortIFDEntry).Value); } // Photo.0x920A (FocalLength/Rational/1) "470/10" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FocalLength); Assert.IsNotNull(entry, "Entry 0x920A missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(470, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(10, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0xA000 (FlashpixVersion/Undefined/4) "48 49 48 48" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FlashpixVersion); Assert.IsNotNull(entry, "Entry 0xA000 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 48, 49, 48, 48 }; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0xA001 (ColorSpace/Short/1) "1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ColorSpace); Assert.IsNotNull(entry, "Entry 0xA001 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(1, (entry as ShortIFDEntry).Value); } // Photo.0xA002 (PixelXDimension/Long/1) "1400" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.PixelXDimension); Assert.IsNotNull(entry, "Entry 0xA002 missing in IFD 0"); Assert.IsNotNull(entry as LongIFDEntry, "Entry is not a long!"); Assert.AreEqual(1400, (entry as LongIFDEntry).Value); } // Photo.0xA003 (PixelYDimension/Long/1) "933" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.PixelYDimension); Assert.IsNotNull(entry, "Entry 0xA003 missing in IFD 0"); Assert.IsNotNull(entry as LongIFDEntry, "Entry is not a long!"); Assert.AreEqual(933, (entry as LongIFDEntry).Value); } // Photo.0xA005 (InteroperabilityTag/SubIFD/1) "3948492" { var entry = exif_structure.GetEntry(0, (ushort)IFDEntryTag.InteroperabilityIFD); Assert.IsNotNull(entry, "Entry 0xA005 missing in IFD 0"); Assert.IsNotNull(entry as SubIFDEntry, "Entry is not a sub IFD!"); } // Photo.0xA217 (SensingMethod/Short/1) "2" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.SensingMethod); Assert.IsNotNull(entry, "Entry 0xA217 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(2, (entry as ShortIFDEntry).Value); } // Photo.0xA300 (FileSource/Undefined/1) "3" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FileSource); Assert.IsNotNull(entry, "Entry 0xA300 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 3 }; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0xA301 (SceneType/Undefined/1) "1" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.SceneType); Assert.IsNotNull(entry, "Entry 0xA301 missing in IFD 0"); Assert.IsNotNull(entry as UndefinedIFDEntry, "Entry is not an undefined IFD entry!"); var parsed_bytes = (entry as UndefinedIFDEntry).Data.Data; var bytes = new byte [] { 1 }; Assert.AreEqual(bytes, parsed_bytes); } // Photo.0xA401 (CustomRendered/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.CustomRendered); Assert.IsNotNull(entry, "Entry 0xA401 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0xA402 (ExposureMode/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.ExposureMode); Assert.IsNotNull(entry, "Entry 0xA402 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0xA403 (WhiteBalance/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.WhiteBalance); Assert.IsNotNull(entry, "Entry 0xA403 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0xA404 (DigitalZoomRatio/Rational/1) "0/10" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.DigitalZoomRatio); Assert.IsNotNull(entry, "Entry 0xA404 missing in IFD 0"); Assert.IsNotNull(entry as RationalIFDEntry, "Entry is not a rational!"); Assert.AreEqual(0, (entry as RationalIFDEntry).Value.Numerator); Assert.AreEqual(10, (entry as RationalIFDEntry).Value.Denominator); } // Photo.0xA405 (FocalLengthIn35mmFilm/Short/1) "280" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.FocalLengthIn35mmFilm); Assert.IsNotNull(entry, "Entry 0xA405 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(280, (entry as ShortIFDEntry).Value); } // Photo.0xA406 (SceneCaptureType/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.SceneCaptureType); Assert.IsNotNull(entry, "Entry 0xA406 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0xA407 (GainControl/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.GainControl); Assert.IsNotNull(entry, "Entry 0xA407 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0xA408 (Contrast/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.Contrast); Assert.IsNotNull(entry, "Entry 0xA408 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0xA409 (Saturation/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.Saturation); Assert.IsNotNull(entry, "Entry 0xA409 missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Photo.0xA40A (Sharpness/Short/1) "0" { var entry = exif_structure.GetEntry(0, (ushort)ExifEntryTag.Sharpness); Assert.IsNotNull(entry, "Entry 0xA40A missing in IFD 0"); Assert.IsNotNull(entry as ShortIFDEntry, "Entry is not a short!"); Assert.AreEqual(0, (entry as ShortIFDEntry).Value); } // Image.0x8825 (GPSTag/SubIFD/1) "650" { var entry = structure.GetEntry(0, (ushort)IFDEntryTag.GPSIFD); Assert.IsNotNull(entry, "Entry 0x8825 missing in IFD 0"); Assert.IsNotNull(entry as SubIFDEntry, "Entry is not a sub IFD!"); } // ---------- End of IFD tests ---------- }