Table of Contents

Class ImageAttachmentHeader

Namespace
MailFathom.Application.Emails.Extraction.Images
Assembly
MailFathom.Application.dll

What an image's own header says it is and how large a grid it declares.

public sealed record ImageAttachmentHeader : IEquatable<ImageAttachmentHeader>
Inheritance
ImageAttachmentHeader
Implements
Inherited Members

Remarks

This is a read of a few octets and never a decode. Nothing here allocates for a pixel grid, expands a compressed stream, or hands the octets to a codec, which is what makes it safe to run on an attachment a stranger composed: a file declaring a grid of billions of pixels costs the same few comparisons as one declaring a thumbnail, and it is refused on the declaration rather than on the allocation the declaration would have caused.

The grid is what the file declares. Nothing here proves the compressed data behind it matches, because proving that is the decode this exists to avoid; a file whose header understates its content is refused by whatever decodes it next, having never been sent under a bound this deployment believed.

Constructors

ImageAttachmentHeader(ImageAttachmentFormat, int, int)

What an image's own header says it is and how large a grid it declares.

Properties

Format

The format the octets are in, decided from the octets rather than from any declared media type.

Height

The declared height in pixels.

MediaType

Gets the media type the octets are actually in, which is what a request states rather than what the part declared.

PixelCount

Gets how many pixels the declared grid holds.

Width

The declared width in pixels.

Methods

TryRead(ReadOnlySpan<byte>, out ImageAttachmentHeader?, out ImageDescriptionRefusal)

Reads what the octets declare themselves to be, or names why they will not be described.