From ed4044a115f0e439107b3681ad267f6f76e3e138 Mon Sep 17 00:00:00 2001 From: Colin McMillen Date: Tue, 19 Sep 2023 22:18:12 -0400 Subject: [PATCH] put raws into root folder, jpgs into jpg/. thumbnail size tweaked to be the same as what uigeometry says --- Photo.cs | 21 +++++++++------------ Program.cs | 7 ++++--- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/Photo.cs b/Photo.cs index a8de019..1943ad3 100644 --- a/Photo.cs +++ b/Photo.cs @@ -169,21 +169,20 @@ public class Photo { String.Format("{0:D2}", DateTimeOriginal.Month), String.Format("{0:D2}", DateTimeOriginal.Day)); Directory.CreateDirectory(directory); - Directory.CreateDirectory(Path.Combine(directory, "1-raw")); - Directory.CreateDirectory(Path.Combine(directory, "2-jpg")); - Directory.CreateDirectory(Path.Combine(directory, "3-edit")); + Directory.CreateDirectory(Path.Combine(directory, "jpg")); string baseFilename = Path.GetFileName(Filename); string rawFilename = Path.ChangeExtension(Filename, "cr3"); + // FIXME: if there's a JPG but not a RAW, make a "RAW" that's the + // camera's original JPG converted to something lossless (PNG? TIFF?). if (Path.Exists(rawFilename)) { - string rawOut = Path.Combine(directory, "1-raw", Path.GetFileName(rawFilename)); + string rawOut = Path.Combine(directory, Path.GetFileName(rawFilename)); if (!Path.Exists(rawOut)) { System.IO.File.Copy(rawFilename, rawOut); toast.Set($"{rawFilename} => {rawOut}"); } } - // FIXME: add comments / captions as ImageDescription? using (Image image = await Image.LoadAsync(Filename)) { Util.RotateImageFromExif(image, Orientation); @@ -215,19 +214,17 @@ public class Photo { image.Metadata.XmpProfile = UpdateXmp(image.Metadata.XmpProfile); - string jpgOut = Path.Combine(directory, "2-jpg", baseFilename); - await image.SaveAsync(jpgOut, new JpegEncoder() { Quality = 100 }); - toast.Set($"{Filename} => {jpgOut}"); - if (RotationDegreeHundredths != 0) { image.Mutate(x => x.Rotate(RotationDegreeHundredths / 100f)); } if (CropRectangle != Rectangle.Empty) { image.Mutate(x => x.Crop(CropRectangle)); } - string editOut = Path.Combine(directory, "3-edit", baseFilename); - await image.SaveAsync(editOut, new JpegEncoder() { Quality = 100 }); - toast.Set($"{Filename} => {editOut}"); + + string jpgOut = Path.Combine(directory, "jpg", baseFilename); + await image.SaveAsync(jpgOut, new JpegEncoder() { Quality = 100 }); + toast.Set($"{Filename} => {jpgOut}"); + // 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 f1d93f8..76d93d1 100644 --- a/Program.cs +++ b/Program.cs @@ -341,6 +341,7 @@ public class UiGeometry { public static Vector2i MIN_WINDOW_SIZE = new(1024, 768); public readonly Vector2i WindowSize; + public readonly Vector2i ThumbnailSize; public readonly Box2i ThumbnailBox; public readonly List ThumbnailBoxes = new(); public readonly List StarBoxes = new(); @@ -355,8 +356,8 @@ public class UiGeometry { int numThumbnailsPerColumn = Math.Max(WindowSize.Y / 100, 1); int thumbnailHeight = WindowSize.Y / numThumbnailsPerColumn; int thumbnailWidth = (int) (1.0 * thumbnailHeight * CameraInfo.AspectRatio); + ThumbnailSize = new(thumbnailWidth, thumbnailHeight); - Console.WriteLine($"thumbnail size: {thumbnailWidth}x{thumbnailHeight}"); int thumbnailColumns = 3; for (int j = thumbnailColumns; j > 0; j--) { for (int i = 0; i < numThumbnailsPerColumn; i++) { @@ -846,7 +847,7 @@ public class Game : GameWindow { // 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\17\2-jpg"); + string[] files = Directory.GetFiles(@"c:\users\colin\desktop\import"); // 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\"); @@ -948,7 +949,7 @@ public class Game : GameWindow { List tasks = new(); foreach (Photo p in allPhotos) { tasks.Add(Task.Run( () => { - p.LoadThumbnailAsync(new Vector2i(150, 150)); + p.LoadThumbnailAsync(geometry.ThumbnailSize); lock (numThumbnailsLoadedLock) { numThumbnailsLoaded++; toast.Set($"[{numThumbnailsLoaded}/{allPhotos.Count}] Loading thumbnails");