From 063cb2f449fd357b4bb4db1809a877d4c85b3f28 Mon Sep 17 00:00:00 2001 From: Colin McMillen Date: Sun, 17 Sep 2023 14:39:00 -0400 Subject: [PATCH] pass along some Toast to newly-named saveAsync() --- Photo.cs | 8 ++++---- Program.cs | 7 +++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Photo.cs b/Photo.cs index a0bfad2..a8de019 100644 --- a/Photo.cs +++ b/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, diff --git a/Program.cs b/Program.cs index e2c2db2..48ba6e6 100644 --- a/Program.cs +++ b/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}"); } })); }