pass along some Toast to newly-named saveAsync()
This commit is contained in:
parent
5c8aa2520a
commit
063cb2f449
8
Photo.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?
|
// FIXME: if nothing was changed about this image, just copy the file bytes directly, possibly with metadata changed?
|
||||||
string directory = Path.Combine(
|
string directory = Path.Combine(
|
||||||
outputRoot,
|
outputRoot,
|
||||||
@ -178,8 +178,8 @@ public class Photo {
|
|||||||
if (Path.Exists(rawFilename)) {
|
if (Path.Exists(rawFilename)) {
|
||||||
string rawOut = Path.Combine(directory, "1-raw", Path.GetFileName(rawFilename));
|
string rawOut = Path.Combine(directory, "1-raw", Path.GetFileName(rawFilename));
|
||||||
if (!Path.Exists(rawOut)) {
|
if (!Path.Exists(rawOut)) {
|
||||||
Console.WriteLine($"{rawFilename} => {rawOut}");
|
|
||||||
System.IO.File.Copy(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);
|
image.Metadata.XmpProfile = UpdateXmp(image.Metadata.XmpProfile);
|
||||||
|
|
||||||
string jpgOut = Path.Combine(directory, "2-jpg", baseFilename);
|
string jpgOut = Path.Combine(directory, "2-jpg", baseFilename);
|
||||||
Console.WriteLine($"{Filename} => {jpgOut}");
|
|
||||||
await image.SaveAsync(jpgOut, new JpegEncoder() { Quality = 100 });
|
await image.SaveAsync(jpgOut, new JpegEncoder() { Quality = 100 });
|
||||||
|
toast.Set($"{Filename} => {jpgOut}");
|
||||||
|
|
||||||
if (RotationDegreeHundredths != 0) {
|
if (RotationDegreeHundredths != 0) {
|
||||||
image.Mutate(x => x.Rotate(RotationDegreeHundredths / 100f));
|
image.Mutate(x => x.Rotate(RotationDegreeHundredths / 100f));
|
||||||
@ -226,8 +226,8 @@ public class Photo {
|
|||||||
image.Mutate(x => x.Crop(CropRectangle));
|
image.Mutate(x => x.Crop(CropRectangle));
|
||||||
}
|
}
|
||||||
string editOut = Path.Combine(directory, "3-edit", baseFilename);
|
string editOut = Path.Combine(directory, "3-edit", baseFilename);
|
||||||
Console.WriteLine($"{Filename} => {editOut}");
|
|
||||||
await image.SaveAsync(editOut, new JpegEncoder() { Quality = 100 });
|
await image.SaveAsync(editOut, new JpegEncoder() { Quality = 100 });
|
||||||
|
toast.Set($"{Filename} => {editOut}");
|
||||||
// await image.SaveAsync(editOut, new PngEncoder() {
|
// await image.SaveAsync(editOut, new PngEncoder() {
|
||||||
// BitDepth = PngBitDepth.Bit8, ChunkFilter = PngChunkFilter.None, ColorType = PngColorType.Rgb,
|
// BitDepth = PngBitDepth.Bit8, ChunkFilter = PngChunkFilter.None, ColorType = PngColorType.Rgb,
|
||||||
// CompressionLevel = PngCompressionLevel.BestCompression, FilterMethod = PngFilterMethod.Adaptive,
|
// CompressionLevel = PngCompressionLevel.BestCompression, FilterMethod = PngFilterMethod.Adaptive,
|
||||||
|
@ -843,8 +843,8 @@ public class Game : GameWindow {
|
|||||||
// Load photos from a directory.
|
// Load photos from a directory.
|
||||||
// string[] files = Directory.GetFiles(@"c:\users\colin\desktop\photos-test\");
|
// 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\07\14\");
|
||||||
string[] files = Directory.GetFiles(@"c:\users\colin\pictures\photos\2023\09\06\jpg");
|
// string[] files = Directory.GetFiles(@"c:\users\colin\pictures\photos\2023\09\06\jpg");
|
||||||
// string[] files = Directory.GetFiles(@"G:\DCIM\100EOSR6\");
|
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\totte-output\2023\08\03");
|
||||||
// string[] files = Directory.GetFiles(@"c:\users\colin\desktop\export");
|
// string[] files = Directory.GetFiles(@"c:\users\colin\desktop\export");
|
||||||
// string[] files = Directory.GetFiles(@"C:\Users\colin\Pictures\photos\2018\06\23");
|
// string[] files = Directory.GetFiles(@"C:\Users\colin\Pictures\photos\2018\06\23");
|
||||||
@ -974,10 +974,9 @@ public class Game : GameWindow {
|
|||||||
numPhotosExported = 0;
|
numPhotosExported = 0;
|
||||||
foreach (Photo p in photos) {
|
foreach (Photo p in photos) {
|
||||||
tasks.Add(Task.Run( () => {
|
tasks.Add(Task.Run( () => {
|
||||||
p.SaveAsJpegAsync(outputRoot);
|
p.SaveAsync(outputRoot, toast);
|
||||||
lock (numPhotosExportedLock) {
|
lock (numPhotosExportedLock) {
|
||||||
numPhotosExported++;
|
numPhotosExported++;
|
||||||
toast.Set($"[{numPhotosExported}/{numPhotosToExport}] Exported {outputRoot}/{p.Filename}");
|
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user