Le 16 osservazioni confermate della revisione, ognuna con la sua prova: - JPEG: il controllo stima la memoria di lavoro del decodificatore (progressivo), così un file che non si decodifica esce «troppo grande» e non «illeggibile». - Un EXIF che non si tiene lascia un EXIF minimo con l'orientamento, perché la foto convertita non esca girata. - Fotogrammi: istanti in millisecondi interi; la copia trova l'indice del nome dall'istante, non dall'ordine delle righe. - Video di durata sconosciuta misurati prima di registrare: contano nei limiti di 500 per richiesta e 5000 per video. - Rimuxaggio: la durata del segmento di elst passa nell'MP4, la fine tagliata resta nascosta (anche nei fotogrammi). - H.264: il punto di recupero vale come IDR solo con exact_match_flag. - MP3 in MP4: objectTypeIndication 0x69 fino a 24 kHz, 0x6B oltre. - Conversione della libreria: il lavoro toglie le righe di un formato spento o cambiato; spegnere toglie anche i «Non riuscito»; «Riprova» solo i formati di adesso; pausa per spazio prima di rileggere l'originale. - «Anche i N» conta e mette in coda solo il tipo che si cambia; le impostazioni dell'esportazione si salvano una per volta. - Eliminazione e «Tieni il più grande» scelgono i convertiti nella stessa transazione: nessun convertito orfano. - Un file arrivato tardi in un elemento vecchio mette in coda solo sé (file nuovo = salvato da quando il formato è scelto). - Zip dei fotogrammi a pezzi di 64 KB: un browser lento che legge non si interrompe, uno fermo sì. Decisioni in docs/decisioni.md (28/11), §4.10 della specifica precisato. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
82 lines
4.4 KiB
C#
82 lines
4.4 KiB
C#
namespace Febe.Core.Codecs.Images;
|
|
|
|
/// <summary>A text an image carries (PNG tEXt, zTXt, iTXt; GIF comment; JPEG COM).</summary>
|
|
/// <param name="Keyword">The keyword («Title», «Comment», «XML:com.adobe.xmp»...); empty for a GIF or JPEG comment.</param>
|
|
/// <param name="Text">The text.</param>
|
|
/// <param name="Language">The language tag of an iTXt chunk, empty otherwise.</param>
|
|
/// <param name="TranslatedKeyword">The translated keyword of an iTXt chunk, empty otherwise.</param>
|
|
public sealed record ImageText(string Keyword, string Text, string Language = "", string TranslatedKeyword = "");
|
|
|
|
/// <summary>Metadata read from an image file, without interpreting it.</summary>
|
|
public sealed class ImageMetadata
|
|
{
|
|
/// <summary>No metadata.</summary>
|
|
public static ImageMetadata Empty { get; } = new();
|
|
|
|
/// <summary>The EXIF block as a TIFF structure (starts with «II*\0» or «MM\0*»), or null.</summary>
|
|
public byte[]? Exif { get; init; }
|
|
|
|
/// <summary>
|
|
/// The EXIF orientation, 1-8 (T.81 has none of its own: it is the Orientation tag of <see cref="Exif"/>); 1 when the
|
|
/// image has no EXIF block, no such tag or an invalid value. The decoders never apply it to the pixels.
|
|
/// </summary>
|
|
public int Orientation { get; init; } = 1;
|
|
|
|
/// <summary>The ICC colour profile, decompressed, or null.</summary>
|
|
public byte[]? IccProfile { get; init; }
|
|
|
|
/// <summary>The name of the ICC profile as the file gives it, or null.</summary>
|
|
public string? IccProfileName { get; init; }
|
|
|
|
/// <summary>The XMP packet (from the iTXt chunk «XML:com.adobe.xmp» of a PNG, the APP1 segment of a JPEG), or null.</summary>
|
|
public string? Xmp { get; init; }
|
|
|
|
/// <summary>The texts, in file order (the XMP packet is in <see cref="Xmp"/>, not here).</summary>
|
|
public IReadOnlyList<ImageText> Texts { get; init; } = [];
|
|
|
|
/// <summary>
|
|
/// 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.
|
|
/// </summary>
|
|
public IReadOnlyList<string> ColorChunks { get; init; } = [];
|
|
|
|
/// <summary>
|
|
/// Blocks of the file that hold data no reader of Febe interprets and no encoder writes, in file order and once
|
|
/// each: JPEG segments («APP13» for IPTC/Photoshop, «ExtendedXmp», «APP2» for MPF, other «APPn»), PNG ancillary
|
|
/// chunks («pHYs», «tIME»...), WebP chunks. A conversion reports them as not kept.
|
|
/// </summary>
|
|
public IReadOnlyList<string> Unread { get; init; } = [];
|
|
}
|
|
|
|
/// <summary>What a file says about its image, read without decoding the pixels.</summary>
|
|
/// <param name="Format">The format.</param>
|
|
/// <param name="Width">Width in pixels, as stored (no EXIF orientation applied).</param>
|
|
/// <param name="Height">Height in pixels, as stored.</param>
|
|
/// <param name="FrameCount">Frames of an animation (GIF images, APNG frames); 1 for a still image.</param>
|
|
/// <param name="HasAlpha">Whether the format of the pixels can carry transparency (not whether any pixel is transparent).</param>
|
|
/// <param name="Metadata">The metadata.</param>
|
|
public sealed record ImageInfo(ImageFormat Format, int Width, int Height, int FrameCount, bool HasAlpha, ImageMetadata Metadata)
|
|
{
|
|
/// <summary>
|
|
/// 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.
|
|
/// </summary>
|
|
public int BitsPerSample { get; init; } = 8;
|
|
|
|
/// <summary>
|
|
/// Whether the file is an animation, by the presence of its marks (spec §4.10): a PNG with an <c>acTL</c> chunk
|
|
/// before its image data, a WebP with an <c>ANIM</c> or <c>ANMF</c> chunk, a GIF with more than one image.
|
|
/// </summary>
|
|
public bool IsAnimated { get; init; }
|
|
|
|
/// <summary>Whether the pixels are stored as CMYK or YCCK (a JPEG with four components).</summary>
|
|
public bool IsCmyk { get; init; }
|
|
|
|
/// <summary>
|
|
/// The working memory a full decode asks besides the decoded image, as the decoder checks it against
|
|
/// <see cref="ImageLimits.MaxWorkingBytes"/> (a progressive or lossless JPEG keeps its coefficients or samples:
|
|
/// up to 9 bytes a pixel); 0 when the format's decoder needs none worth counting before it starts.
|
|
/// </summary>
|
|
public long DecodeWorkingBytes { get; init; }
|
|
}
|