feat: owner review 2 phase 4b: mass conversion after import (#13)
CI / Build and test (push) Failing after 3m1s
CI / PostgreSQL 16 integration (push) Skipped
CI / PostgreSQL 17 integration (push) Skipped
CI / Docker image (push) Skipped
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 10s
Release / Build, test and publish (push) Successful in 15m31s
Release / Server image (push) Successful in 1m13s
CI / Build and test (push) Failing after 3m1s
CI / PostgreSQL 16 integration (push) Skipped
CI / PostgreSQL 17 integration (push) Skipped
CI / Docker image (push) Skipped
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 10s
Release / Build, test and publish (push) Successful in 15m31s
Release / Server image (push) Successful in 1m13s
Convert photos already in the archive to JPEG, TIFF-16 or Linear DNG, from the panel's Library and the desktop's Archive and Library. Each run asks Replace (same frames, originals to the trash, recoverable) or New sequence. A dry run lists what converts, what is skipped and why, size before and after, and free space; the job converts exactly the confirmed photos, resumes, and commits all or nothing per sequence. A conversion never changes what Chronos reads from a photo. Replaced originals are erased only on the archive's own word that their conversion is gone. Desktop TIFFs that WIC showed black or as noise now go to the managed reader; the Edit picker no longer spins a core. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #13.
This commit is contained in:
1 parent
7e4a3b481d
commit
efa87f68ce
354 files changed
+24530
-843
No files matched your search
@@ -194,6 +194,78 @@ public sealed class TiffTests(TestContext context)
|
||||
Assert.Throws<InvalidDataException>(() => TiffImageReader.ToImageBuffer(raster));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Samples that are not gray, RGB or linear RAW are refused before their pixels are read, from the headers alone too,
|
||||
/// never decoded as gray from their first plane (a CMYK red read as black, owner review 2, R7).
|
||||
/// </summary>
|
||||
[Theory]
|
||||
[Case(5, 4)] // CMYK
|
||||
[Case(8, 3)] // CIELab
|
||||
[Case(3, 1)] // palette
|
||||
[Case(2, 1)] // RGB of one sample
|
||||
[Case(32844, 1)] // LogL
|
||||
public void SamplesItDoesNotRenderAreRefusedNotReadAsGray(int photometric, int samples)
|
||||
{
|
||||
// A CMYK red: no cyan, full magenta and yellow, no black.
|
||||
var pixel = Enumerable.Range(0, samples).Select(c => (byte)(c is 1 or 2 ? 255 : 0)).ToArray();
|
||||
var tiff = Conversion.ColorFixtures.Tiff(6, 4, (ushort)photometric, pixel);
|
||||
Assert.Throws<InvalidDataException>(() => TiffImageReader.Decode(tiff));
|
||||
Assert.Throws<InvalidDataException>(() => TiffImageReader.ReadInfo(new MemoryStream(tiff)));
|
||||
Assert.Throws<InvalidDataException>(() => TiffImageReader.ToImageBuffer(Raster(tiff)));
|
||||
}
|
||||
|
||||
/// <summary>The headers say what <see cref="TiffImageReader.Decode(Stream, TiffDecodeOptions?)"/> reads, and refuse what it refuses.</summary>
|
||||
[Test]
|
||||
public void ReadInfoSaysWhatDecodeReads()
|
||||
{
|
||||
foreach (var name in (string[])["tiff/lzw-pred.tif", "tiff/lzw-tiled.tif", "tiff/planar-zip.tif", "tiff/jpeg-ycbcr.tif", "tiff/float32-pred3.tif", "tiff/gray-miniswhite.tif"])
|
||||
{
|
||||
using var image = TiffImageReader.Decode(Fixture(name));
|
||||
Assert.Equal((image.Width, image.Height), TiffImageReader.ReadInfo(new MemoryStream(Fixture(name))), name);
|
||||
}
|
||||
var rgb = Conversion.ColorFixtures.Tiff(6, 4, 2, [10, 20, 30]);
|
||||
Assert.Equal((6, 4), TiffImageReader.ReadInfo(new MemoryStream(rgb)));
|
||||
// More samples than the decoder takes, a compression it lacks (ZSTD), float samples whose white is 0, no strips.
|
||||
Assert.Throws<InvalidDataException>(() => TiffImageReader.ReadInfo(new MemoryStream(rgb), new TiffDecodeOptions { MaxSamples = 6 * 4 * 3 - 1 }));
|
||||
Assert.Throws<InvalidDataException>(() => TiffImageReader.ReadInfo(new MemoryStream(Conversion.ColorFixtures.Tiff(6, 4, 2, [1, 2, 3], d => d.Short(TiffTags.Compression, 50000)))));
|
||||
var floatWhiteIsZero = TiffTestEncoders.Build(d =>
|
||||
{
|
||||
Layout(d, 2, 2, 1, 32, compression: 1);
|
||||
d.Short(TiffTags.PhotometricInterpretation, 0);
|
||||
d.Short(TiffTags.SampleFormat, 3);
|
||||
}, [new byte[16]], tiled: false);
|
||||
Assert.Throws<InvalidDataException>(() => TiffImageReader.ReadInfo(new MemoryStream(floatWhiteIsZero)));
|
||||
Assert.Throws<InvalidDataException>(() => TiffImageReader.Decode(floatWhiteIsZero));
|
||||
using var noStrips = new MemoryStream();
|
||||
noStrips.Write("II*\0\0\0\0\0"u8);
|
||||
var directory = new TiffDirectory();
|
||||
Layout(directory, 6, 4, 3, 8, compression: 1);
|
||||
TiffWriter.WriteDirectory(noStrips, 0, directory);
|
||||
Assert.Throws<InvalidDataException>(() => TiffImageReader.ReadInfo(new MemoryStream(noStrips.ToArray())));
|
||||
// Tiles that no count holds are a malformed file, not an arithmetic error, to a decode as to the headers: a chain
|
||||
// that finds them refused asks its next decoder.
|
||||
var tiles = Conversion.ColorFixtures.Tiff(6, 4, 2, [1, 2, 3], d =>
|
||||
{
|
||||
d.Long(TiffTags.ImageWidth, int.MaxValue);
|
||||
d.Long(TiffTags.ImageLength, int.MaxValue);
|
||||
d.Long(TiffTags.TileWidth, 1);
|
||||
d.Long(TiffTags.TileLength, 1);
|
||||
d.Long(TiffTags.TileOffsets, 8);
|
||||
});
|
||||
var unbounded = new TiffDecodeOptions { MaxSamples = long.MaxValue };
|
||||
Assert.Throws<InvalidDataException>(() => TiffImageReader.ReadInfo(new MemoryStream(tiles), unbounded));
|
||||
Assert.Throws<InvalidDataException>(() => TiffImageReader.Decode(tiles, unbounded));
|
||||
// More strips than the reader takes (one row each), refused before any is read.
|
||||
var strips = Conversion.ColorFixtures.Tiff(6, 4, 1, [1], d =>
|
||||
{
|
||||
d.Long(TiffTags.ImageWidth, 1);
|
||||
d.Long(TiffTags.ImageLength, (1 << 24) + 1);
|
||||
d.Long(TiffTags.RowsPerStrip, 1);
|
||||
});
|
||||
Assert.Throws<InvalidDataException>(() => TiffImageReader.ReadInfo(new MemoryStream(strips)));
|
||||
Assert.Throws<InvalidDataException>(() => TiffImageReader.Decode(strips));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[Case(8, 1, TiffCompression.None, false)]
|
||||
[Case(8, 3, TiffCompression.Deflate, true)]
|
||||
|
||||
Reference in new issue
Block a user