fix(convert): a conversion never changes what Chronos reads from a photo
Owner review 2, phase 4b, fix round 3 (codecs). Chronos's decoders never read an ICC profile: they take code values through the sRGB curve and float samples as they are. Round 2 wrote a float TIFF's values with its profile's own curves, so after a Replace the renders, thumbnails, analyses and deflicker of an Adobe RGB, ProPhoto or gamma-1.0 float TIFF saw other pixels (up to 2.7 EV darker, shadows lifted). Every converted file now holds the values the decoders read from the original, as they read them back, and says truthfully what they are: - A JPEG or TIFF-16 keeps the codes of code values and carries the original's profile. Float values are written as sRGB codes with a profile made for them: the original's colorants and media white with the sRGB curve. A gray profile's codes are kept, its curve carried as an RGB profile (they were converted to sRGB before, which changed them too). - A Linear DNG, whose matrices Chronos develops it with as well, takes only values that are sRGB's as the decoders read them; any other profile is refused as color_profile instead of converted to colours Chronos would then show differently. - A profile with colorant tags that convert nothing is never sRGB by its name. - A float file with NaN or infinite samples fails as damaged data instead of being written black (and spending a DNG's headroom). The plan and the decoders behind it: - TooLarge and WorstBytes answer any size, int.MaxValue sides included, without a product that wraps around; the worst case saturates. - A frame another host flagged unreadable (the server, for a CMYK or CIELab TIFF its reader refuses) is asked again with a small decode where the conversion has other decoders (WIC on a PC), so a PC still converts it. The too_large sentences say "or Chronos reads back" (en, it). - WIC's TIFF decoder decodes an unknown compression as zeros, does not undo the floating-point predictor of Photoshop's 32-bit files and reads 32-bit integers as floats, all without an error: such TIFFs are left to the managed reader, on the desktop as in conversions, never black or noise. - A conversion's WIC probe reads the headers (decoder, first frame's oriented size, pixel format), so the size bound applies to what only WIC reads; a read error stays a read error (inaccessible), never a verdict. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4dd3050334
commit
b471a33bfc
16 files changed
+1341
-330
No files matched your search
@@ -24,6 +24,9 @@ public sealed class ManagedDecoderProvider : IImageDecoderProvider
|
||||
private const long MaxPreviewBytes = 256L << 20;
|
||||
private static readonly string[] CompanionExtensions = [".JPG", ".jpg", ".JPEG", ".jpeg"];
|
||||
|
||||
/// <summary>The provider whose probes read headers (<see cref="WithHeaderProbes"/>); it holds nothing else.</summary>
|
||||
private static readonly ManagedDecoderProvider HeaderProbes = new() { ReadsHeaders = true };
|
||||
|
||||
public string Name => "managed";
|
||||
|
||||
/// <summary>
|
||||
@@ -35,6 +38,9 @@ public sealed class ManagedDecoderProvider : IImageDecoderProvider
|
||||
/// </summary>
|
||||
public bool ReadsHeaders { get; init; }
|
||||
|
||||
/// <summary>A provider whose probes read the headers of JPEG, PNG and TIFF files (<see cref="ReadsHeaders"/>).</summary>
|
||||
public IImageDecoderProvider WithHeaderProbes() => ReadsHeaders ? this : HeaderProbes;
|
||||
|
||||
public DecodeTier? TierFor(ImageFileFormat format)
|
||||
{
|
||||
var info = ImageFormatInfo.Of(format);
|
||||
|
||||
Reference in new issue
Block a user