public void CheckImageOrientation() { string basePath = "../../../exif-samples-master/jpg/orientation/"; // There are 8 possible orientation values and we have test images for each one. for (int i = 1; i <= 8; i++) { string landscapeName = string.Format("{0}landscape_{1}.jpg", basePath, i); string portraitName = string.Format("{0}portrait_{1}.jpg", basePath, i); // Check landscape mode photos EXIFParser landscapeParser = new EXIFParser(landscapeName); bool parsedOK = landscapeParser.ParseTags(); Assert.True(parsedOK, "Image tags could not be parsed for " + landscapeName); if (parsedOK) { Assert.True((UInt16)(landscapeParser.Tags["Orientation"]) == i, landscapeName + " did not have expected orientation tag"); } // Check portrait mode photos EXIFParser portraitParser = new EXIFParser(portraitName); parsedOK = portraitParser.ParseTags(); Assert.True(parsedOK, "Image tags could not be parsed for " + portraitName); if (parsedOK) { Assert.True((UInt16)(portraitParser.Tags["Orientation"]) == i, portraitName + " did not have expected orientation tag"); } } }
private static void PrintImageTags(string imagePath) { if (!File.Exists(imagePath)) { Console.WriteLine("File not found: " + imagePath); return; } Console.WriteLine("Scanning file: " + imagePath); EXIFParser parser = new EXIFParser(imagePath); if (parser.ParseTags()) { Console.WriteLine("Detected Tags:"); foreach (string key in parser.Tags.Keys) { string s = string.Format("{0}: {1}", key, parser.Tags[key]); Console.WriteLine(s); } } else { Console.WriteLine("No valid tags detected."); } }
public void CheckHeicTags() { string basePath = "../../../HeicTest/"; string testImagePath = basePath + "test1.heic"; EXIFParser parser = new EXIFParser(testImagePath); bool parsedOK = parser.ParseTags(); Assert.True(parsedOK, "Image tags could not be parsed for " + testImagePath); if (parsedOK) { // TODO: check more fields here Assert.True(parser.Tags["Make"].Equals("Apple"), "Make tag is not correct"); } }
private void CheckAllImagesAtPath(string path) { string[] extensions = new string[] { ".jpg", ".jpeg", ".heic" }; List <string> imageFiles = Directory.GetFiles(path) .Where(file => extensions.Any(file.ToLower().EndsWith)) .ToList(); foreach (string img in imageFiles) { EXIFParser parser = new EXIFParser(img); parser.ParseTags(); } // Recursively search folders for more images string[] directories = Directory.GetDirectories(path); foreach (string dir in directories) { CheckAllImagesAtPath(dir); } }