CI / Build and test (push) Successful in 8m14s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 13m19s
CI / PostgreSQL 16 integration (push) Successful in 4m49s
CI / PostgreSQL 17 integration (push) Successful in 5m28s
CI / Docker image (push) Successful in 53s
Release / Server image (push) Failing after 10s
The owner renamed the product and moved the repository to the self-hosted Gitea (https://gitea.encke-hake.ts.net/BalboSoft/Chronos) for more control, and asked for Actions and a first automatic release with the server package and the Windows exe (docs/requests/2026-10-23-chronos-gitea.md). - Chronos everywhere: a byte-exact rename of contents and paths, then a per-language review of the forms the old name's ending had dictated. - Gitea instead of GitHub: the update check, licence, issue and support links read ChronosReleasesUrl; the update check takes the highest stable version, offers a pre-release build its final release and reports a repository it cannot see as a failed check. EULA, security policy and Gitea issue forms live at the repository root. - Gitea Actions for the Linux act_runner (.gitea/workflows): CI, release, nightly image and performance gates in the .NET SDK container with git checkout and the system SQLite. The release cross-compiles the Windows programs, checks their icon, version and DPI manifest, packs installers and zips, publishes the Gitea release and pushes the server image (REGISTRY_TOKEN). Windows-only tests run in an opt-in job on a Windows runner (WINDOWS_RUNNER). - New Chronos.Tools commands: zip, gitea-release, postgres-ci (replaces the docker-exec script, which Gitea's service containers do not allow; the throw-away server runs without durability) and pe-check. - Timed tests take their budget from TestTiming (CHRONOS_TEST_TIME_FACTOR, 3 on the shared runner; the weekly performance gates keep theirs). BREAKING CHANGE: programs, settings, data folders, file types, environment variables and the Docker image use the new name; nothing is migrated from Titano, which never had a release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
203 lines
7.1 KiB
C#
203 lines
7.1 KiB
C#
using System.Buffers.Binary;
|
|
using Chronos.Core.Imaging;
|
|
using Chronos.Core.Metadata;
|
|
using Chronos.Core.Metadata.Tiff;
|
|
using Chronos.Core.Tests.Metadata.Builders;
|
|
using Chronos.Testing;
|
|
using static Chronos.Core.Tests.Metadata.MetadataTestHelpers;
|
|
|
|
namespace Chronos.Core.Tests.Metadata;
|
|
|
|
/// <summary>RAF, WebP, PNG and the minimal formats (GIF, BMP, JPEG XL, JPEG XR).</summary>
|
|
public sealed class OtherFormatTests
|
|
{
|
|
[Test]
|
|
public void Raf()
|
|
{
|
|
var m = Read(Fixtures.Raf(), "DSCF0001.RAF");
|
|
AssertNoFault(m);
|
|
Assert.Empty(m.Warnings);
|
|
Assert.Equal(ImageFileFormat.Raf, m.Format);
|
|
Assert.Equal("FUJIFILM", m.Make);
|
|
Assert.Equal("X-T5", m.Model);
|
|
Assert.Equal((7752, 5178), (m.Width, m.Height));
|
|
Assert.Equal(14, m.BitsPerSample);
|
|
AssertPreviews(m, (1920, 1280, PreviewKind.Preview), (160, 120, PreviewKind.Thumbnail));
|
|
Assert.Equal("FF02B1234567", m.BodySerial);
|
|
Assert.Equal(6100, m.ColorTemperature);
|
|
Assert.Equal(true, m.ImageStabilization);
|
|
Assert.Equal(Fixtures.Captured, m.CapturedAt);
|
|
}
|
|
|
|
[Test]
|
|
public void RafHeaderModelIsTheFallback()
|
|
{
|
|
var raf = Fixtures.Raf();
|
|
BinaryPrimitives.WriteUInt32BigEndian(raf.AsSpan(0x54), 0);
|
|
var m = Read(raf);
|
|
Assert.Equal("FUJIFILM", m.Make);
|
|
Assert.Equal("X-T5", m.Model);
|
|
Assert.Equal((7752, 5178), (m.Width, m.Height));
|
|
Assert.Contains("RAF embedded JPEG missing", m.Warnings);
|
|
}
|
|
|
|
[Test]
|
|
public void WebPWithVp8xExifAndXmp()
|
|
{
|
|
var m = Read(Fixtures.WebP(), "a.webp");
|
|
AssertNoFault(m);
|
|
Assert.Empty(m.Warnings);
|
|
Assert.Equal(ImageFileFormat.WebP, m.Format);
|
|
Assert.Equal((3000, 2000), (m.Width, m.Height));
|
|
Assert.Equal(8, m.BitsPerSample);
|
|
Assert.Equal(Fixtures.Make, m.Make);
|
|
Assert.Equal(Fixtures.Captured, m.CapturedAt);
|
|
Assert.Equal(4, m.Rating);
|
|
Assert.Equal(6, m.Orientation);
|
|
}
|
|
|
|
[Test]
|
|
public void WebPSimpleFormats()
|
|
{
|
|
Assert.Equal((640, 480), Size(Read(Fixtures.WebPLossy(640, 480))));
|
|
var body = (byte[])[.. "WEBP"u8, .. Box.Riff("VP8L", Fixtures.Vp8L(400, 300))];
|
|
Assert.Equal((400, 300), Size(Read([.. "RIFF"u8, .. LittleEndian(body.Length), .. body])));
|
|
}
|
|
|
|
[Test]
|
|
public void WebPExifWithPrefix()
|
|
{
|
|
var body = (byte[])[.. "WEBP"u8, .. Box.Riff("VP8L", Fixtures.Vp8L(8, 8)), .. Box.Riff("EXIF", [.. "Exif\0\0"u8, .. Fixtures.ExifTiff()])];
|
|
Assert.Equal(Fixtures.Model, Read([.. "RIFF"u8, .. LittleEndian(body.Length), .. body]).Model);
|
|
}
|
|
|
|
[Theory]
|
|
[Case(false)]
|
|
[Case(true)]
|
|
public void Png(bool compressedXmp)
|
|
{
|
|
var m = Read(Fixtures.Png(compressedXmp), "a.png");
|
|
AssertNoFault(m);
|
|
Assert.Empty(m.Warnings);
|
|
Assert.Equal(ImageFileFormat.Png, m.Format);
|
|
Assert.Equal((2048, 1536), (m.Width, m.Height));
|
|
Assert.Equal(16, m.BitsPerSample);
|
|
Assert.Equal(Fixtures.Model, m.Model);
|
|
Assert.Equal(400, m.Iso);
|
|
Assert.Equal("Red", m.Label);
|
|
}
|
|
|
|
[Test]
|
|
public void Gif() => Assert.Equal((320, 200), Size(Read([.. "GIF89a"u8, 0x40, 0x01, 0xC8, 0x00, 0, 0, 0])));
|
|
|
|
[Theory]
|
|
[Case(40, 640, -480)]
|
|
[Case(124, 1024, 768)]
|
|
public void Bmp(int headerSize, int width, int height)
|
|
{
|
|
var bmp = new byte[54];
|
|
"BM"u8.CopyTo(bmp);
|
|
BinaryPrimitives.WriteInt32LittleEndian(bmp.AsSpan(14), headerSize);
|
|
BinaryPrimitives.WriteInt32LittleEndian(bmp.AsSpan(18), width);
|
|
BinaryPrimitives.WriteInt32LittleEndian(bmp.AsSpan(22), height);
|
|
Assert.Equal((width, Math.Abs(height)), Size(Read(bmp)));
|
|
}
|
|
|
|
[Test]
|
|
public void BmpCoreHeader()
|
|
{
|
|
var bmp = new byte[26];
|
|
"BM"u8.CopyTo(bmp);
|
|
bmp[14] = 12;
|
|
BinaryPrimitives.WriteUInt16LittleEndian(bmp.AsSpan(18), 300);
|
|
BinaryPrimitives.WriteUInt16LittleEndian(bmp.AsSpan(20), 200);
|
|
Assert.Equal((300, 200), Size(Read(bmp)));
|
|
}
|
|
|
|
[Theory]
|
|
[Case(256, 128)]
|
|
[Case(1000, 750, Name = "4:3 ratio")]
|
|
[Case(1921, 1081)]
|
|
[Case(300000, 270000, Name = "two 30-bit sizes (68-bit header)")]
|
|
public void JpegXlCodestream(int width, int height)
|
|
{
|
|
var m = Read(BuildJpegXlCodestream(width, height), "a.jxl");
|
|
Assert.Equal(ImageFileFormat.JpegXl, m.Format);
|
|
Assert.Equal((width, height), Size(m));
|
|
}
|
|
|
|
[Test]
|
|
public void JpegXlContainer()
|
|
{
|
|
byte[] file = [.. Box.Make("JXL ", [0x0D, 0x0A, 0x87, 0x0A]), .. Box.Make("ftyp", Box.Ascii("jxl "), Box.U32(0), Box.Ascii("jxl ")),
|
|
.. Box.Make("Exif", Box.U32(0), Fixtures.ExifTiff()), .. Box.Make("jxlp", Box.U32(0), BuildJpegXlCodestream(512, 384))];
|
|
var m = Read(file);
|
|
Assert.Equal(ImageFileFormat.JpegXl, m.Format);
|
|
Assert.Equal((512, 384), Size(m));
|
|
Assert.Equal(Fixtures.Make, m.Make);
|
|
}
|
|
|
|
[Test]
|
|
public void JpegXr()
|
|
{
|
|
var ifd = new IfdSpec().Ascii(TiffTags.Make, "Microsoft").Long(0xBC80, 1600).Long(0xBC81, 900);
|
|
var m = Read(TiffFile.Build(ifd, magic: "II¼\u0001"), "a.jxr");
|
|
Assert.Equal(ImageFileFormat.JpegXr, m.Format);
|
|
Assert.Equal((1600, 900), Size(m));
|
|
Assert.Equal("Microsoft", m.Make);
|
|
}
|
|
|
|
[Test]
|
|
public void UnknownFilesYieldAWarning()
|
|
{
|
|
var m = Read("hello world, not an image"u8.ToArray(), "notes.jpg");
|
|
Assert.Equal(ImageFileFormat.Unknown, m.Format);
|
|
Assert.Contains("Unrecognised file signature", m.Warnings);
|
|
}
|
|
|
|
private static (int, int) Size(FrameMetadata m) => (m.Width, m.Height);
|
|
|
|
private static byte[] LittleEndian(int v)
|
|
{
|
|
var b = new byte[4];
|
|
BinaryPrimitives.WriteInt32LittleEndian(b, v);
|
|
return b;
|
|
}
|
|
|
|
/// <summary>FF 0A + SizeHeader (ISO/IEC 18181-1): small multiples of 8 or U32 distributions; a 4:3 ratio when exact.</summary>
|
|
private static byte[] BuildJpegXlCodestream(int width, int height)
|
|
{
|
|
var bits = new List<bool>();
|
|
void Put(ulong value, int count)
|
|
{
|
|
for (var i = 0; i < count; i++) bits.Add(((value >> i) & 1) != 0);
|
|
}
|
|
void PutU32(int value)
|
|
{
|
|
var v = (ulong)(value - 1);
|
|
var (selector, n) = v < 1 << 9 ? (0, 9) : v < 1 << 13 ? (1, 13) : v < 1 << 18 ? (2, 18) : (3, 30);
|
|
Put((ulong)selector, 2);
|
|
Put(v, n);
|
|
}
|
|
var small = width % 8 == 0 && height % 8 == 0 && width <= 256 && height <= 256;
|
|
Put(small ? 1UL : 0UL, 1);
|
|
if (small) Put((ulong)(height / 8 - 1), 5);
|
|
else PutU32(height);
|
|
var ratio = height * 4 / 3 == width && height % 3 == 0 ? 3 : 0;
|
|
Put((ulong)ratio, 3);
|
|
if (ratio == 0)
|
|
{
|
|
if (small) Put((ulong)(width / 8 - 1), 5);
|
|
else PutU32(width);
|
|
}
|
|
var bytes = new byte[2 + (bits.Count + 7) / 8 + 8];
|
|
bytes[0] = 0xFF;
|
|
bytes[1] = 0x0A;
|
|
for (var i = 0; i < bits.Count; i++)
|
|
{
|
|
if (bits[i]) bytes[2 + i / 8] |= (byte)(1 << (i % 8));
|
|
}
|
|
return bytes;
|
|
}
|
|
}
|