Browse Source

pass along some Toast to newly-named saveAsync()

main
Colin McMillen 7 months ago
parent
commit
063cb2f449
  1. 8
      Photo.cs
  2. 7
      Program.cs

8
Photo.cs

@ -161,7 +161,7 @@ public class Photo {
}
}
public async void SaveAsJpegAsync(string outputRoot) {
public async void SaveAsync(string outputRoot, Toast toast) {
// FIXME: if nothing was changed about this image, just copy the file bytes directly, possibly with metadata changed?
string directory = Path.Combine(
outputRoot,
@ -178,8 +178,8 @@ public class Photo {
if (Path.Exists(rawFilename)) {
string rawOut = Path.Combine(directory, "1-raw", Path.GetFileName(rawFilename));
if (!Path.Exists(rawOut)) {
Console.WriteLine($"{rawFilename} => {rawOut}");
System.IO.File.Copy(rawFilename, rawOut);
toast.Set($"{rawFilename} => {rawOut}");
}
}
@ -216,8 +216,8 @@ public class Photo {
image.Metadata.XmpProfile = UpdateXmp(image.Metadata.XmpProfile);
string jpgOut = Path.Combine(directory, "2-jpg", baseFilename);
Console.WriteLine($"{Filename} => {jpgOut}");
await image.SaveAsync(jpgOut, new JpegEncoder() { Quality = 100 });
toast.Set($"{Filename} => {jpgOut}");
if (RotationDegreeHundredths != 0) {
image.Mutate(x => x.Rotate(RotationDegreeHundredths / 100f));
@ -226,8 +226,8 @@ public class Photo {
image.Mutate(x => x.Crop(CropRectangle));
}
string editOut = Path.Combine(directory, "3-edit", baseFilename);
Console.WriteLine($"{Filename} => {editOut}");
await image.SaveAsync(editOut, new JpegEncoder() { Quality = 100 });
toast.Set($"{Filename} => {editOut}");
// await image.SaveAsync(editOut, new PngEncoder() {
// BitDepth = PngBitDepth.Bit8, ChunkFilter = PngChunkFilter.None, ColorType = PngColorType.Rgb,
// CompressionLevel = PngCompressionLevel.BestCompression, FilterMethod = PngFilterMethod.Adaptive,

7
Program.cs

@ -843,8 +843,8 @@ public class Game : GameWindow {
// Load photos from a directory.
// string[] files = Directory.GetFiles(@"c:\users\colin\desktop\photos-test\");
// string[] files = Directory.GetFiles(@"c:\users\colin\pictures\photos\2023\07\14\");
string[] files = Directory.GetFiles(@"c:\users\colin\pictures\photos\2023\09\06\jpg");
// string[] files = Directory.GetFiles(@"G:\DCIM\100EOSR6\");
// string[] files = Directory.GetFiles(@"c:\users\colin\pictures\photos\2023\09\06\jpg");
string[] files = Directory.GetFiles(@"G:\DCIM\100EOSR6\");
// string[] files = Directory.GetFiles(@"c:\users\colin\desktop\totte-output\2023\08\03");
// string[] files = Directory.GetFiles(@"c:\users\colin\desktop\export");
// string[] files = Directory.GetFiles(@"C:\Users\colin\Pictures\photos\2018\06\23");
@ -974,10 +974,9 @@ public class Game : GameWindow {
numPhotosExported = 0;
foreach (Photo p in photos) {
tasks.Add(Task.Run( () => {
p.SaveAsJpegAsync(outputRoot);
p.SaveAsync(outputRoot, toast);
lock (numPhotosExportedLock) {
numPhotosExported++;
toast.Set($"[{numPhotosExported}/{numPhotosToExport}] Exported {outputRoot}/{p.Filename}");
}
}));
}

Loading…
Cancel
Save