Ejemplo n.º 1
0
 public void TestExifDirectory_MatchesKnownValues()
 {
     Assert.Equal("          ", _exifIfd0Directory.GetString(ExifDirectoryBase.TagImageDescription));
     Assert.Equal("NIKON", _exifIfd0Directory.GetString(ExifDirectoryBase.TagMake));
     Assert.Equal("E995", _exifIfd0Directory.GetString(ExifDirectoryBase.TagModel));
     Assert.Equal(300, _exifIfd0Directory.GetDouble(ExifDirectoryBase.TagXResolution), 3);
     Assert.Equal(300, _exifIfd0Directory.GetDouble(ExifDirectoryBase.TagYResolution), 3);
     Assert.Equal(2, _exifIfd0Directory.GetInt32(ExifDirectoryBase.TagResolutionUnit));
     Assert.Equal("E995v1.6", _exifIfd0Directory.GetString(ExifDirectoryBase.TagSoftware));
     Assert.Equal("2002:08:29 17:31:40", _exifIfd0Directory.GetString(ExifDirectoryBase.TagDateTime));
     Assert.Equal(1, _exifIfd0Directory.GetInt32(ExifDirectoryBase.TagYcbcrPositioning));
     Assert.Equal(new Rational(2439024, 100000000), _exifSubIfdDirectory.GetRational(ExifDirectoryBase.TagExposureTime));
     Assert.Equal(2.6, _exifSubIfdDirectory.GetDouble(ExifDirectoryBase.TagFnumber), 3);
     Assert.Equal(2, _exifSubIfdDirectory.GetInt32(ExifDirectoryBase.TagExposureProgram));
     Assert.Equal(100, _exifSubIfdDirectory.GetInt32(ExifDirectoryBase.TagIsoEquivalent));
     Assert.Equal("48 50 49 48", _exifSubIfdDirectory.GetString(ExifDirectoryBase.TagExifVersion));
     Assert.Equal("2002:08:29 17:31:40", _exifSubIfdDirectory.GetString(ExifDirectoryBase.TagDateTimeDigitized));
     Assert.Equal("2002:08:29 17:31:40", _exifSubIfdDirectory.GetString(ExifDirectoryBase.TagDateTimeOriginal));
     Assert.Equal("1 2 3 0", _exifSubIfdDirectory.GetString(ExifDirectoryBase.TagComponentsConfiguration));
     Assert.Equal(0, _exifSubIfdDirectory.GetInt32(ExifDirectoryBase.TagExposureBias));
     Assert.Equal("0", _exifSubIfdDirectory.GetString(ExifDirectoryBase.TagMaxAperture));
     Assert.Equal(5, _exifSubIfdDirectory.GetInt32(ExifDirectoryBase.TagMeteringMode));
     Assert.Equal(0, _exifSubIfdDirectory.GetInt32(ExifDirectoryBase.TagWhiteBalance));
     Assert.Equal(1, _exifSubIfdDirectory.GetInt32(ExifDirectoryBase.TagFlash));
     Assert.Equal(8.2, _exifSubIfdDirectory.GetDouble(ExifDirectoryBase.TagFocalLength), 3);
     Assert.Equal("0 0 0 0 0 0 0 0 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32", _exifSubIfdDirectory.GetString(ExifDirectoryBase.TagUserComment));
     Assert.Equal("48 49 48 48", _exifSubIfdDirectory.GetString(ExifDirectoryBase.TagFlashpixVersion));
     Assert.Equal(1, _exifSubIfdDirectory.GetInt32(ExifDirectoryBase.TagColorSpace));
     Assert.Equal(2048, _exifSubIfdDirectory.GetInt32(ExifDirectoryBase.TagExifImageWidth));
     Assert.Equal(1536, _exifSubIfdDirectory.GetInt32(ExifDirectoryBase.TagExifImageHeight));
     Assert.Equal(3, _exifSubIfdDirectory.GetInt32(ExifDirectoryBase.TagFileSource));
     Assert.Equal(1, _exifSubIfdDirectory.GetInt32(ExifDirectoryBase.TagSceneType));
 }
Ejemplo n.º 2
0
        /// <summary>Parses <see cref="ExifIfd0Directory" /> metadata and saves it to the <see cref="Photo" />.</summary>
        /// <param name="directory">Directory containing the make, model and datetime metadata.</param>
        /// <param name="photo">Photo object used for storing metadata.</param>
        public static void Parse(this ExifIfd0Directory directory, Photo photo)
        {
            if (directory is null || photo is null)
            {
                return;
            }

            var make  = directory.GetString(ExifIfd0Directory.TagMake);
            var model = directory.GetString(ExifIfd0Directory.TagModel);

            photo.Make  = make;
            photo.Model = model;

            if (directory.TryGetDateTime(ExifIfd0Directory.TagDateTime, out var datetime))
            {
                photo.DateTime = datetime;
            }
        }
 public void TestExifDirectory_MatchesKnownValues()
 {
     Assert.Equal("          ", _exifIfd0Directory.GetString(ExifDirectoryBase.TagImageDescription));
     Assert.Equal("NIKON", _exifIfd0Directory.GetString(ExifDirectoryBase.TagMake));
     Assert.Equal("E950", _exifIfd0Directory.GetString(ExifDirectoryBase.TagModel));
     Assert.Equal(1, _exifIfd0Directory.GetInt32(ExifDirectoryBase.TagOrientation));
     Assert.Equal(300, _exifIfd0Directory.GetDouble(ExifDirectoryBase.TagXResolution), 3);
     Assert.Equal(300, _exifIfd0Directory.GetDouble(ExifDirectoryBase.TagYResolution), 3);
     Assert.Equal(2, _exifIfd0Directory.GetInt32(ExifDirectoryBase.TagResolutionUnit));
     Assert.Equal("v981-79", _exifIfd0Directory.GetString(ExifDirectoryBase.TagSoftware));
     Assert.Equal("2001:04:06 11:51:40", _exifIfd0Directory.GetString(ExifDirectoryBase.TagDateTime));
     Assert.Equal(2, _exifIfd0Directory.GetInt32(ExifDirectoryBase.TagYcbcrPositioning));
     Assert.Equal(new Rational(1, 77), _exifSubIfdDirectory.GetRational(ExifDirectoryBase.TagExposureTime));
     Assert.Equal(5.5, _exifSubIfdDirectory.GetDouble(ExifDirectoryBase.TagFnumber), 3);
     Assert.Equal(2, _exifSubIfdDirectory.GetInt32(ExifDirectoryBase.TagExposureProgram));
     Assert.Equal(80, _exifSubIfdDirectory.GetInt32(ExifDirectoryBase.TagIsoEquivalent));
     Assert.Equal("48 50 49 48", _exifSubIfdDirectory.GetString(ExifDirectoryBase.TagExifVersion));
     Assert.Equal("2001:04:06 11:51:40", _exifSubIfdDirectory.GetString(ExifDirectoryBase.TagDateTimeDigitized));
     Assert.Equal("2001:04:06 11:51:40", _exifSubIfdDirectory.GetString(ExifDirectoryBase.TagDateTimeOriginal));
     Assert.Equal("1 2 3 0", _exifSubIfdDirectory.GetString(ExifDirectoryBase.TagComponentsConfiguration));
     Assert.Equal(4, _exifSubIfdDirectory.GetInt32(ExifDirectoryBase.TagCompressedAverageBitsPerPixel));
     Assert.Equal(0, _exifSubIfdDirectory.GetInt32(ExifDirectoryBase.TagExposureBias));
     // this 2.6 *apex*, which is F2.5
     Assert.Equal(2.6, _exifSubIfdDirectory.GetDouble(ExifDirectoryBase.TagMaxAperture), 3);
     Assert.Equal(5, _exifSubIfdDirectory.GetInt32(ExifDirectoryBase.TagMeteringMode));
     Assert.Equal(0, _exifSubIfdDirectory.GetInt32(ExifDirectoryBase.TagWhiteBalance));
     Assert.Equal(0, _exifSubIfdDirectory.GetInt32(ExifDirectoryBase.TagFlash));
     Assert.Equal(12.8, _exifSubIfdDirectory.GetDouble(ExifDirectoryBase.TagFocalLength), 3);
     Assert.Equal("0 0 0 0 0 0 0 0 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32", _exifSubIfdDirectory.GetString(ExifDirectoryBase.TagUserComment));
     Assert.Equal("48 49 48 48", _exifSubIfdDirectory.GetString(ExifDirectoryBase.TagFlashpixVersion));
     Assert.Equal(1, _exifSubIfdDirectory.GetInt32(ExifDirectoryBase.TagColorSpace));
     Assert.Equal(1600, _exifSubIfdDirectory.GetInt32(ExifDirectoryBase.TagExifImageWidth));
     Assert.Equal(1200, _exifSubIfdDirectory.GetInt32(ExifDirectoryBase.TagExifImageHeight));
     Assert.Equal(3, _exifSubIfdDirectory.GetInt32(ExifDirectoryBase.TagFileSource));
     Assert.Equal(1, _exifSubIfdDirectory.GetInt32(ExifDirectoryBase.TagSceneType));
     Assert.Equal(6, _thumbDirectory.GetInt32(ExifDirectoryBase.TagCompression));
     Assert.Equal(2036, _thumbDirectory.GetInt32(ExifThumbnailDirectory.TagThumbnailOffset));
     Assert.Equal(4662, _thumbDirectory.GetInt32(ExifThumbnailDirectory.TagThumbnailLength));
 }