-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
59 lines (51 loc) · 2.17 KB
/
Program.cs
File metadata and controls
59 lines (51 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using MetadataExtractor;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
namespace ImageExifScanner
{
class Program
{
private static string folder = @"e:\our pics";
private static string saveFile = @"e:\image_metadata_ourpics.txt";
private static char saveFileDelimiter = '?';
private static string[] extensions = { "*.jpg", "*.png", "*.jpeg" };
//string[] extensions = { "*.jpg", "*.gif", "*.png", "*.jpeg", "*.tiff", "*.bmp", "*.webp", "*.psd", "*.raw" };
private static ConcurrentQueue<ImageDetails> _imageDetailsQueue = new ConcurrentQueue<ImageDetails>();
public static async Task Main(string[] args)
{
Parallel.ForEach(extensions, (extension) =>
{
Console.WriteLine($"Processing {extension} files...");
string[] allFiles = System.IO.Directory.GetFiles(folder, extension, SearchOption.AllDirectories);
Parallel.ForEach(allFiles, (currentFile) =>
{
IEnumerable<MetadataExtractor.Directory> directories = ImageMetadataReader.ReadMetadata(currentFile);
foreach (var d in directories)
foreach (var t in d.Tags)
{
_imageDetailsQueue.Enqueue(new ImageDetails
{
FileName = currentFile,
ExifPropertyType = t.Name,
ExifString = t.Description
});
}
});
});
using var outStream = new StreamWriter(saveFile);
foreach (var j in _imageDetailsQueue)
{
await outStream.WriteLineAsync($"{j.FileName}{saveFileDelimiter}{j.ExifPropertyType}{saveFileDelimiter}{j.ExifString}");
}
}
}
public class ImageDetails
{
public string FileName { get; set; }
public string ExifPropertyType { get; set; }
public string ExifString { get; set; }
}
}