public void FileIndexItemTest_SetColorClassTest2() { var input = ColorClassParser.GetColorClass("2"); var output = ColorClassParser.Color.WinnerAlt; Assert.AreEqual(input, output); }
public void FileIndexItemTest_SetColorClassTestMin1() { var input = ColorClassParser.GetColorClass("-1"); var output = ColorClassParser.Color.DoNotChange; Assert.AreEqual(input, output); }
public void FileIndexItemTest_SetColorClassTest0() { var input = ColorClassParser.GetColorClass("0"); var output = ColorClassParser.Color.None; Assert.AreEqual(input, output); }
public void FileIndexItemTest_SetColorClassTest8() { var input = ColorClassParser.GetColorClass("8"); var output = ColorClassParser.Color.Trash; Assert.AreEqual(input, output); }
public void FileIndexItemTest_SetColorClassTest7() { var input = ColorClassParser.GetColorClass("7"); var output = ColorClassParser.Color.Extras; Assert.AreEqual(input, output); }
public void FileIndexItemTest_SetColorClassTest6() { var input = ColorClassParser.GetColorClass("6"); var output = ColorClassParser.Color.TypicalAlt; Assert.AreEqual(input, output); }
public void FileIndexItemTest_SetColorClassTest4() { var input = ColorClassParser.GetColorClass("4"); var output = ColorClassParser.Color.SuperiorAlt; Assert.AreEqual(input, output); }
private FileIndexItem ParseExifDirectory(List <MetadataExtractor.Directory> allExifItems, FileIndexItem item) { // Used to overwrite feature if (item == null) { throw new ArgumentException("need to fill item with filepath"); } // Set the default value item.ColorClass = ColorClassParser.GetColorClass(); // Set the default value item.Orientation = item.SetAbsoluteOrientation("1"); item.Latitude = GetGeoLocationLatitude(allExifItems); item.Longitude = GetGeoLocationLongitude(allExifItems); item.LocationAltitude = GetGeoLocationAltitude(allExifItems); item.SetImageWidth(GetImageWidthHeight(allExifItems, true)); item.SetImageHeight(GetImageWidthHeight(allExifItems, false)); // Update imageFormat based on Exif data var imageFormat = GetFileSpecificTags(allExifItems); if (imageFormat != ExtensionRolesHelper.ImageFormat.unknown) { item.ImageFormat = imageFormat; } foreach (var exifItem in allExifItems) { // exifItem.Tags var tags = GetExifKeywords(exifItem); if (!string.IsNullOrEmpty(tags)) // null = is not the right tag or empty tag { item.Tags = tags; } // Colour Class => ratings var colorClassString = GetColorClassString(exifItem); if (!string.IsNullOrEmpty(colorClassString)) // null = is not the right tag or empty tag { item.ColorClass = ColorClassParser.GetColorClass(colorClassString); } // [IPTC] Caption/Abstract var caption = GetCaptionAbstract(exifItem); if (!string.IsNullOrEmpty(caption)) // null = is not the right tag or empty tag { item.Description = caption; } // [IPTC] Object Name = Title var title = GetObjectName(exifItem); if (!string.IsNullOrEmpty(title)) // null = is not the right tag or empty tag { item.Title = title; } // Orientation of image var orientation = GetOrientationFromExifItem(exifItem); if (orientation != FileIndexItem.Rotation.DoNotChange) { item.Orientation = orientation; } // [IPTC] City = Diepenveen var locationCity = GetLocationPlaces(exifItem, "City", "photoshop:City"); if (!string.IsNullOrEmpty(locationCity)) // null = is not the right tag or empty tag { item.LocationCity = locationCity; } // [IPTC] Province/State = Overijssel var locationState = GetLocationPlaces(exifItem, "Province/State", "photoshop:State"); if (!string.IsNullOrEmpty(locationState)) // null = is not the right tag or empty tag { item.LocationState = locationState; } // [IPTC] Country/Primary Location Name = Nederland var locationCountry = GetLocationPlaces(exifItem, "Country/Primary Location Name", "photoshop:Country"); if (!string.IsNullOrEmpty(locationCountry)) // null = is not the right tag or empty tag { item.LocationCountry = locationCountry; } // [Exif SubIFD] Aperture Value = f/2.2 var aperture = GetAperture(exifItem); if (Math.Abs(aperture) > 0) // 0f = is not the right tag or empty tag { item.Aperture = aperture; } // [Exif SubIFD] Shutter Speed Value = 1/2403 sec var shutterSpeed = GetShutterSpeedValue(exifItem); if (shutterSpeed != string.Empty) // string.Empty = is not the right tag or empty tag { item.ShutterSpeed = shutterSpeed; } // [Exif SubIFD] ISO Speed Ratings = 25 var isoSpeed = GetIsoSpeedValue(exifItem); if (isoSpeed != 0) // 0 = is not the right tag or empty tag { item.SetIsoSpeed(isoSpeed); } var lensModel = GetMakeLensModel(exifItem); if (lensModel != string.Empty) { item.SetMakeModel(lensModel, 2); } // [Exif SubIFD] Focal Length = 200 mm var focalLength = GetFocalLength(exifItem); if (Math.Abs(focalLength) > 0.00001) { item.FocalLength = focalLength; } } var make = GetMakeModel(allExifItems, true); if (make != string.Empty) // string.Empty = is not the right tag or empty tag { item.SetMakeModel(make, 0); } var model = GetMakeModel(allExifItems, false); if (model != string.Empty) // string.Empty = is not the right tag or empty tag { item.SetMakeModel(model, 1); } item.Software = GetSoftware(allExifItems); // last & out of the loop var sonyLensModel = GetSonyMakeLensModel(allExifItems, item.LensModel); if (!string.IsNullOrEmpty(sonyLensModel)) { item.SetMakeModel(sonyLensModel, 2); } item.ImageStabilisation = GetImageStabilisation(allExifItems); // DateTime of image var dateTime = GetExifDateTime(allExifItems, new CameraMakeModel(item.Make, item.Model)); if (dateTime != null) { item.DateTime = (DateTime)dateTime; } return(item); }
/// <summary> /// ContentNameSpace is for example : Namespace=http://... /// </summary> /// <param name="xmp"></param> /// <param name="item"></param> /// <returns></returns> private FileIndexItem GetDataContentNameSpaceTypes(IXmpMeta xmp, FileIndexItem item) { GpsAltitudeRef(xmp, item); foreach (var property in xmp.Properties) { // Path=exif:GPSLatitude Namespace=http://ns.adobe.com/exif/1.0/ Value=52,20.708N var gpsLatitude = GetContentNameSpace(property, "exif:GPSLatitude"); if (gpsLatitude != null) { item.Latitude = GpsPreParseAndConvertDegreeAngleToDouble(gpsLatitude); } // Path=exif:GPSLongitude Namespace=http://ns.adobe.com/exif/1.0/ Value=5,55.840E var gpsLongitude = GetContentNameSpace(property, "exif:GPSLongitude"); if (gpsLongitude != null) { item.Longitude = GpsPreParseAndConvertDegreeAngleToDouble(gpsLongitude); } // Option 1 (Datetime) // Path=exif:DateTimeOriginal Namespace=http://ns.adobe.com/exif/1.0/ Value=2018-07-18T19:44:27 var dateTimeOriginal = GetContentNameSpace(property, "exif:DateTimeOriginal"); if (dateTimeOriginal != null) { DateTime.TryParseExact(dateTimeOriginal, "yyyy-MM-dd\\THH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out var dateTime); if (dateTime.Year >= 3) { item.DateTime = dateTime; } } // Option 2 (Datetime) // Path=xmp:CreateDate Namespace=http://ns.adobe.com/xap/1.0/ Value=2019-03-02T11:29:18+01:00 // Path=xmp:CreateDate Namespace=http://ns.adobe.com/xap/1.0/ Value=2019-03-02T11:29:18 var createDate = GetContentNameSpace(property, "xmp:CreateDate"); if (createDate != null) { DateTime.TryParseExact(createDate, "yyyy-MM-dd\\THH:mm:sszzz", CultureInfo.InvariantCulture, DateTimeStyles.None, out var dateTime); // The other option if (dateTime.Year <= 3) { DateTime.TryParseExact(createDate, "yyyy-MM-dd\\THH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime); } // and use this value item.DateTime = DateTime.SpecifyKind(dateTime, DateTimeKind.Unspecified); } // Path=photomechanic:ColorClass Namespace=http://ns.camerabits.com/photomechanic/1.0/ Value=1 var colorClass = GetContentNameSpace(property, "photomechanic:ColorClass"); if (colorClass != null) { item.ColorClass = ColorClassParser.GetColorClass(colorClass); } // Path=tiff:Orientation Namespace=http://ns.adobe.com/tiff/1.0/ Value=6 var rotation = GetContentNameSpace(property, "tiff:Orientation"); if (rotation != null) { item.SetAbsoluteOrientation(rotation); } // Path=tiff:ImageLength Namespace=http://ns.adobe.com/tiff/1.0/ Value=13656 var height = GetContentNameSpace(property, "tiff:ImageLength"); if (height != null) { item.SetImageHeight(height); } // Path=tiff:ImageWidth Namespace=http://ns.adobe.com/tiff/1.0/ Value=15504 var width = GetContentNameSpace(property, "tiff:ImageWidth"); if (width != null) { item.SetImageWidth(width); } // Path=photoshop:City Namespace=http://ns.adobe.com/photoshop/1.0/ Value=Epe var locationCity = GetContentNameSpace(property, "photoshop:City"); if (locationCity != null) { item.LocationCity = locationCity; } // Path=photoshop:State Namespace=http://ns.adobe.com/photoshop/1.0/ Value=Gelderland var locationState = GetContentNameSpace(property, "photoshop:State"); if (locationState != null) { item.LocationState = locationState; } // Path=photoshop:Country Namespace=http://ns.adobe.com/photoshop/1.0/ Value=Nederland var locationCountry = GetContentNameSpace(property, "photoshop:Country"); if (locationCountry != null) { item.LocationCountry = locationCountry; } // exif:ExposureTime http://ns.adobe.com/exif/1.0/ var shutterSpeed = GetContentNameSpace(property, "exif:ExposureTime"); if (shutterSpeed != null) { item.ShutterSpeed = shutterSpeed; } // exif:FNumber http://ns.adobe.com/exif/1.0/ var aperture = GetContentNameSpace(property, "exif:FNumber"); if (aperture != null) { item.Aperture = MathFraction.Fraction(aperture); } // Path=tiff:Make Namespace=http://ns.adobe.com/tiff/1.0/ Value=SONY var make = GetContentNameSpace(property, "tiff:Make"); if (make != null) { item.SetMakeModel(make, 0); } // Path=tiff:Model Namespace=http://ns.adobe.com/tiff/1.0/ Value=SLT-A58 var model = GetContentNameSpace(property, "tiff:Model"); if (model != null) { item.SetMakeModel(model, 1); } // Path=exif:FocalLength Namespace=http://ns.adobe.com/exif/1.0/ Value=200/1 // Path=exif:FocalLength Namespace=http://ns.adobe.com/exif/1.0/ Value=18/1 var focalLength = GetContentNameSpace(property, "exif:FocalLength"); if (focalLength != null) { item.FocalLength = MathFraction.Fraction(focalLength); } // Path=xmp:CreatorTool Namespace=http://ns.adobe.com/xap/1.0/ Value=SLT-A58 v1.00 var software = GetContentNameSpace(property, "xmp:CreatorTool"); if (software != null) { item.Software = software; } } return(item); }