|
|
@ -221,7 +221,7 @@ public class Photo { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void SaveAsJpeg(string outputRoot, JpegEncoder encoder) { |
|
|
|
public async void SaveAsJpeg(string outputRoot, JpegEncoder encoder) { |
|
|
|
// FIXME: if nothing was changed about this image, just copy the file bytes directly, possibly with metadata changed?
|
|
|
|
string directory = System.IO.Path.Combine( |
|
|
|
outputRoot, |
|
|
@ -232,8 +232,10 @@ public class Photo { |
|
|
|
string filename = System.IO.Path.Combine(directory, System.IO.Path.GetFileName(Filename)); |
|
|
|
Console.WriteLine("saving " + filename); |
|
|
|
// FIXME: update JPEG metadata.
|
|
|
|
// FIXME: warn if the file already exists?
|
|
|
|
using (Image<Rgba32> image = Image.Load<Rgba32>(Filename)) { |
|
|
|
image.Save(filename, encoder); |
|
|
|
// Util.RotateImageFromExif(image, Orientation);
|
|
|
|
await image.SaveAsync(filename, encoder); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -802,8 +804,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(@"G:\DCIM\100EOSR6\");
|
|
|
|
// string[] files = Directory.GetFiles(@"c:\users\colin\pictures\photos\2023\07\14\");
|
|
|
|
string[] files = Directory.GetFiles(@"G:\DCIM\100EOSR6\"); |
|
|
|
// 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\");
|
|
|
@ -886,11 +888,14 @@ public class Game : GameWindow { |
|
|
|
|
|
|
|
// To find the JPEG compression level of a file from the command line:
|
|
|
|
// $ identify -verbose image.jpg | grep Quality:
|
|
|
|
private void ExportPhotos() { |
|
|
|
// FIXME: don't ExportPhotos() if another export is already active.
|
|
|
|
// FIXME: show a progress bar or something.
|
|
|
|
private async void ExportPhotos() { |
|
|
|
JpegEncoder encoder = new JpegEncoder() { Quality = 100 }; |
|
|
|
string outputRoot = @"c:\users\colin\desktop\totte-output"; |
|
|
|
foreach (Photo p in photos) { |
|
|
|
p.SaveAsJpeg(outputRoot, encoder); |
|
|
|
// p.SaveAsJpeg(outputRoot, encoder);
|
|
|
|
await Task.Run( () => { p.SaveAsJpeg(outputRoot, encoder); }); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|