put raws into root folder, jpgs into jpg/. thumbnail size tweaked to be the same as what uigeometry says

This commit is contained in:
Colin McMillen 2023-09-19 22:18:12 -04:00
parent 775252b567
commit ed4044a115
2 changed files with 13 additions and 15 deletions

View File

@ -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<Rgba32> image = await Image.LoadAsync<Rgba32>(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,

View File

@ -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<Box2i> ThumbnailBoxes = new();
public readonly List<Box2i> 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<Task> 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");