pass along some Toast to newly-named saveAsync()

This commit is contained in:
Colin McMillen 2023-09-17 14:39:00 -04:00
parent 5c8aa2520a
commit 063cb2f449
2 changed files with 7 additions and 8 deletions

View File

@ -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,

View File

@ -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}");
}
}));
}