Working on new method

This commit is contained in:
2019-12-16 21:18:54 +01:00
parent 9bf4b675e4
commit a17ea99642
2 changed files with 34 additions and 3 deletions

View File

@@ -1,6 +1,9 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using ExifLibrary;
using JetBrains.Annotations;
namespace PhotoRenamer.Base
{
@@ -22,5 +25,31 @@ namespace PhotoRenamer.Base
}
}
}
public static IEnumerable<MediaFile> GetMediaFiles([NotNull] IEnumerable<string> files)
{
if (files == null) throw new ArgumentNullException(nameof(files));
foreach (var file in files)
{
var imageFile = ImageFile.FromFile(file);
var dateTime = imageFile.Properties.Get<ExifDateTime>(ExifTag.DateTimeOriginal);
var mediaFile = new MediaFile(file, dateTime.Value);
yield return mediaFile;
}
}
}
public class MediaFile
{
public string Path { get; }
public DateTime CreationDate { get; }
public MediaFile(string path, DateTime creationDate)
{
Path = path;
CreationDate = creationDate;
}
}
}