feat(core): archive layout, sidecars, leases and thumbnail packs
archive.json and sequence.json with source-generated JSON, forward-compatible reading (unknown fields kept, unknown enum names tolerated) and atomic writes; lease files with expiry and stale takeover; thumbs.pack with index, crash-safe append and random access; folder scanning, in-place adoption, reconcile, verify, index snapshot, rename planning and thumbnail/proxy rendering. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
24 files changed
+2556
No files matched your search
@@ -0,0 +1,51 @@
|
||||
using Titano.Core.Codecs.Jpeg;
|
||||
using Titano.Core.Imaging;
|
||||
using Titano.Core.Metadata;
|
||||
|
||||
namespace Titano.Core.Tests.Archiving;
|
||||
|
||||
/// <summary>Small real JPEGs with Exif (capture time, camera) made by the in-house encoder; each seed gives distinct bytes.</summary>
|
||||
internal static class TestPhotos
|
||||
{
|
||||
public static byte[] Jpeg(DateTime captured, int seed, string make = "Canon", string model = "Canon EOS R5", string? serial = "0431",
|
||||
int width = 48, int height = 32, int orientation = 1)
|
||||
{
|
||||
using var image = new ImageBuffer(width, height);
|
||||
var random = new Random(seed);
|
||||
for (var c = 0; c < 3; c++)
|
||||
{
|
||||
var plane = image.Plane(c);
|
||||
var level = (float)random.NextDouble();
|
||||
for (var i = 0; i < plane.Length; i++) plane[i] = level * (0.5f + 0.5f * (i % width) / width);
|
||||
}
|
||||
var exif = ExifWriter.BuildJpegApp1(new FrameMetadata
|
||||
{
|
||||
Make = make,
|
||||
Model = model,
|
||||
BodySerial = serial,
|
||||
CapturedAt = captured,
|
||||
ExposureTime = 1.0 / 125,
|
||||
FNumber = 8,
|
||||
Iso = 100,
|
||||
Orientation = orientation,
|
||||
});
|
||||
return JpegEncoder.Encode(image, new JpegEncodeOptions { Quality = 85, App1Segments = [exif[4..]] });
|
||||
}
|
||||
|
||||
public static string Write(string path, DateTime captured, int seed, string make = "Canon", string model = "Canon EOS R5", string? serial = "0431")
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(path)!);
|
||||
File.WriteAllBytes(path, Jpeg(captured, seed, make, model, serial));
|
||||
return path;
|
||||
}
|
||||
|
||||
/// <summary>Writes <paramref name="count"/> photos named IMG_0001.JPG… taken every <paramref name="interval"/>.</summary>
|
||||
public static List<string> WriteSeries(string directory, DateTime start, int count, TimeSpan interval, int firstSeed = 1, string prefix = "IMG_",
|
||||
string make = "Canon", string model = "Canon EOS R5", int firstNumber = 1)
|
||||
{
|
||||
var paths = new List<string>(count);
|
||||
for (var i = 0; i < count; i++)
|
||||
paths.Add(Write(Path.Combine(directory, $"{prefix}{firstNumber + i:0000}.JPG"), start + interval * i, firstSeed + i, make, model));
|
||||
return paths;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user