parse SubsecTimeOriginal

This commit is contained in:
Colin McMillen 2023-08-30 23:18:25 -04:00
parent 5d70b4c54b
commit 4f86338a3e
2 changed files with 11 additions and 5 deletions

View File

@ -172,7 +172,6 @@ public class Photo {
String.Format("{0:D2}", DateTimeOriginal.Day));
Directory.CreateDirectory(directory);
string filename = System.IO.Path.Combine(directory, System.IO.Path.GetFileName(Filename));
Console.WriteLine("saving " + filename);
// FIXME: add comments / captions as ImageDescription?
// FIXME: warn if the file already exists?
using (Image<Rgba32> image = await Image.LoadAsync<Rgba32>(Filename)) {
@ -210,6 +209,7 @@ public class Photo {
image.Metadata.XmpProfile = UpdateXmp(image.Metadata.XmpProfile);
await image.SaveAsync(filename, encoder);
Console.WriteLine("saved " + filename);
}
}
@ -347,7 +347,6 @@ public class Photo {
}
}
// FIXME: there is also a SubSecTimeOriginal tag we could use to get fractional seconds.
// FIXME: I think the iPhone stores time in UTC but other cameras report it in local time.
IExifValue<string>? dateTimeOriginal;
if (exifs.TryGetValue(ExifTag.DateTimeOriginal, out dateTimeOriginal)) {
@ -364,6 +363,13 @@ public class Photo {
}
}
IExifValue<string>? subsecTimeOriginal;
if (exifs.TryGetValue(ExifTag.SubsecTimeOriginal, out subsecTimeOriginal)) {
double fractionalSeconds;
Double.TryParse("0." + subsecTimeOriginal.Value, out fractionalSeconds);
DateTimeOriginal = DateTimeOriginal.AddSeconds(fractionalSeconds);
}
Gps = GpsInfo.ParseExif(exifs);
}
@ -408,7 +414,7 @@ public class Photo {
}
public string Description() {
string date = DateTimeOriginal.ToString("yyyy-MM-dd HH:mm:ss");
string date = DateTimeOriginal.ToString("yyyy-MM-dd HH:mm:ss.ff");
return String.Format(
"{0,6} {1,-5} {2,-7} {3,-10} {7,4}x{8,-4} {4} {5,-20} {6}",
FocalLength, FNumber, ExposureTime, IsoSpeed, date, ShortLensModel, Filename, Size.X, Size.Y);

View File

@ -697,10 +697,10 @@ public class Game : GameWindow {
// string[] files = Directory.GetFiles(@"c:\users\colin\pictures\photos\2023\07\23\");
// string[] files = Directory.GetFiles(@"G:\DCIM\100EOSR6\");
// string[] files = Directory.GetFiles(@"c:\users\colin\desktop\totte-output\2023\08\29");
// string[] files = Directory.GetFiles(@"c:\users\colin\desktop\import");
string[] files = Directory.GetFiles(@"c:\users\colin\desktop\import");
// string[] files = Directory.GetFiles(@"C:\Users\colin\Pictures\photos\2018\06\23");
// string[] files = Directory.GetFiles(@"C:\Users\colin\Desktop\Germany all\104D7000");
string[] files = Directory.GetFiles(@"C:\Users\colin\Desktop\many-birds\");
// string[] files = Directory.GetFiles(@"C:\Users\colin\Desktop\many-birds\");
for (int i = 0; i < files.Count(); i++) {
string file = files[i];