namespace Febe.Core.Codecs.Images; /// A text an image carries (PNG tEXt, zTXt, iTXt; GIF comment; JPEG COM). /// The keyword («Title», «Comment», «XML:com.adobe.xmp»...); empty for a GIF or JPEG comment. /// The text. /// The language tag of an iTXt chunk, empty otherwise. /// The translated keyword of an iTXt chunk, empty otherwise. public sealed record ImageText(string Keyword, string Text, string Language = "", string TranslatedKeyword = ""); /// Metadata read from an image file, without interpreting it. public sealed class ImageMetadata { /// No metadata. public static ImageMetadata Empty { get; } = new(); /// The EXIF block as a TIFF structure (starts with «II*\0» or «MM\0*»), or null. public byte[]? Exif { get; init; } /// /// The EXIF orientation, 1-8 (T.81 has none of its own: it is the Orientation tag of ); 1 when the /// image has no EXIF block, no such tag or an invalid value. The decoders never apply it to the pixels. /// public int Orientation { get; init; } = 1; /// The ICC colour profile, decompressed, or null. public byte[]? IccProfile { get; init; } /// The name of the ICC profile as the file gives it, or null. public string? IccProfileName { get; init; } /// The XMP packet (from the iTXt chunk «XML:com.adobe.xmp» of a PNG, the APP1 segment of a JPEG), or null. public string? Xmp { get; init; } /// The texts, in file order (the XMP packet is in , not here). public IReadOnlyList Texts { get; init; } = []; /// /// The PNG chunks that describe the colour of the pixels (gAMA, cHRM, sRGB) the file has, in file order. They are /// not applied to the pixels and no encoder writes them, so a conversion says they are left behind. /// public IReadOnlyList ColorChunks { get; init; } = []; } /// What a file says about its image, read without decoding the pixels. /// The format. /// Width in pixels, as stored (no EXIF orientation applied). /// Height in pixels, as stored. /// Frames of an animation (GIF images, APNG frames); 1 for a still image. /// Whether the format of the pixels can carry transparency (not whether any pixel is transparent). /// The metadata. public sealed record ImageInfo(ImageFormat Format, int Width, int Height, int FrameCount, bool HasAlpha, ImageMetadata Metadata) { /// /// Bits of one sample as the file stores them (PNG bit depth, JPEG precision, BMP mask width; 8 for palettes and /// for GIF and WebP). The decoders give 8-bit samples, so above 8 the decoded pixels have lost precision. /// public int BitsPerSample { get; init; } = 8; }