ImageMetadata Class

Mutable image-wide metadata: orientation, resolution, pixel aspect ratio, color profile, transfer function, CICP color description, content light level, mastering display color volume, EXIF, XMP and text entries.

public sealed class ImageMetadata

Remarks

ImageMetadata.Clone produces an independent container: mutable state (such as ImageMetadata.TextEntries) is copied, while immutable values (profiles, blobs, text entries) are shared.

When an image is saved, metadata the encoder cannot represent causes an UnsupportedImageFeatureException unless the encoder's ImageEncoder.MetadataHandling allows discarding it.

Constructors

NameDescription
ImageMetadata()

ImageMetadata()

ImageMetadata.cs
public ImageMetadata()

No documentation is available.

Properties

NameDescription
CicpGets or sets the CICP color description of the pixels, or null when none is signalled (the pixels are assumed sRGB, or described by ImageMetadata.IccProfile).
ContentLightLevelGets or sets the content light level of high dynamic range pixels, or null when none is declared.
ExifProfileGets or sets the EXIF profile, or null if none.
IccProfileGets or sets the ICC color profile, or null if the pixels are untagged (assumed sRGB or sGray).
MasteringDisplayGets or sets the color volume of the display the pixels were mastered on, or null when none is declared.
OpenExrWindowsGets or sets the windows of the OpenEXR file the image was decoded from, or null for the other formats. This is informational only, like ImageMetadata.SourceFormat: it describes the file, not the pixels.
OrientationGets or sets the orientation of the stored pixels. Defaults to ExifOrientation.TopLeft.
PixelAspectRatioGets or sets the aspect ratio of the pixels, or null when none is declared (the pixels are square).
ResolutionGets or sets the physical resolution, or null if unspecified.
SourceFormatGets or sets the format the image was decoded from. This is informational only and never selects an output format.
TextEntriesGets the textual entries, in file order. null entries are rejected.
TransferFunctionGets or sets the transfer function of the stored color samples. Defaults to ColorTransferFunction.Srgb (sRGB encoded, or described by ImageMetadata.IccProfile).
XmpProfileGets or sets the XMP packet, or null if none.

Gets or sets the CICP color description of the pixels, or null when none is signalled (the pixels are assumed sRGB, or described by ImageMetadata.IccProfile).

public CicpColorDescription? Cicp { get; set; }

Property value

CicpColorDescription?

Remarks

This is a label: loading and saving never convert the pixels. When an ImageMetadata.IccProfile is also present, the profile describes the color primaries and the transfer function. Without profile, ImageProcessingExtensions.ConvertColorProfile converts the pixels from the color space of the description (and removes it), and linear-light resizing and convolution decode the samples with the function of its transfer characteristics. AVIF and HEIC files declare a description, and so do the JPEG XL files whose enumerated color encoding has code points. The AVIF and HEIC encoders store any description and the JPEG XL encoder the ones the format can enumerate; the other encoders treat a description that is not equivalent to sRGB as metadata they cannot store (ImageEncoder.MetadataHandling).

ContentLightLevel

ImageMetadata.cs

Gets or sets the content light level of high dynamic range pixels, or null when none is declared.

public ContentLightLevel? ContentLightLevel { get; set; }

Property value

ContentLightLevel?

Remarks

This is a label: no operation computes it from the pixels, and the operations that keep the color space of the pixels keep it. ImageProcessingExtensions.ConvertColorProfile removes it, since it no longer describes the converted pixels. Only AVIF stores it; the other encoders treat it as metadata they cannot store (ImageEncoder.MetadataHandling).

ExifProfile

ImageMetadata.cs

Gets or sets the EXIF profile, or null if none.

public ExifProfile? ExifProfile { get; set; }

Property value

ExifProfile?

Gets or sets the ICC color profile, or null if the pixels are untagged (assumed sRGB or sGray).

public IccProfile? IccProfile { get; set; }

Property value

IccProfile?

MasteringDisplay

ImageMetadata.cs

Gets or sets the color volume of the display the pixels were mastered on, or null when none is declared.

public MasteringDisplayColorVolume? MasteringDisplay { get; set; }

Property value

MasteringDisplayColorVolume?

Remarks

This is a label: it does not describe the color space of the pixels (ImageMetadata.Cicp or ImageMetadata.IccProfile does). ImageProcessingExtensions.ConvertColorProfile removes it, since it no longer describes the converted pixels. Only AVIF stores it; the other encoders treat it as metadata they cannot store (ImageEncoder.MetadataHandling).

OpenExrWindows

ImageMetadata.cs

Gets or sets the windows of the OpenEXR file the image was decoded from, or null for the other formats. This is informational only, like ImageMetadata.SourceFormat: it describes the file, not the pixels.

public OpenExrWindows? OpenExrWindows { get; set; }

Property value

OpenExrWindows?

Remarks

No operation updates it, and every encoder ignores it: OpenExrEncoder writes both windows from (0, 0), the size of the image.

Orientation

ImageMetadata.cs

Gets or sets the orientation of the stored pixels. Defaults to ExifOrientation.TopLeft.

public ExifOrientation Orientation { get; set; }

Property value

ExifOrientation

Exceptions

ArgumentOutOfRangeException
The value is not a defined ExifOrientation.

Remarks

This typed value is authoritative: it overrides the orientation tag of ImageMetadata.ExifProfile when serialized.

PixelAspectRatio

ImageMetadata.cs

Gets or sets the aspect ratio of the pixels, or null when none is declared (the pixels are square).

public PixelAspectRatio? PixelAspectRatio { get; set; }

Property value

PixelAspectRatio?

Remarks

This is a label: no operation resamples the pixels to make them square. The operations that swap the axes of the image swap its terms. Only AVIF stores it; the other encoders treat a ratio that is not square as metadata they cannot store (ImageEncoder.MetadataHandling).

Gets or sets the physical resolution, or null if unspecified.

public ImageResolution? Resolution { get; set; }

Property value

ImageResolution?

SourceFormat

ImageMetadata.cs

Gets or sets the format the image was decoded from. This is informational only and never selects an output format.

public ImageFormat SourceFormat { get; set; }

Property value

ImageFormat

TextEntries

ImageMetadata.cs

Gets the textual entries, in file order. null entries are rejected.

public IList<ImageTextEntry> TextEntries { get; }

Property value

IList<ImageTextEntry>

TransferFunction

ImageMetadata.cs

Gets or sets the transfer function of the stored color samples. Defaults to ColorTransferFunction.Srgb (sRGB encoded, or described by ImageMetadata.IccProfile).

public ColorTransferFunction TransferFunction { get; set; }

Property value

ColorTransferFunction

Exceptions

ArgumentOutOfRangeException
The value is not a defined ColorTransferFunction.

Remarks

This is a label: setting it does not convert the pixels. ImageProcessingExtensions.ConvertColorProfile converts ColorTransferFunction.Linear samples as linear light and resets the label. Linear-light resizing (ResizeWorkingSpace.LinearSrgb) and convolution (ConvolutionWorkingSpace.LinearSrgb) filter ColorTransferFunction.Linear samples directly, as they already are linear light. Only QOI and JPEG XL store ColorTransferFunction.Linear; other encoders treat it as metadata they cannot store (ImageEncoder.MetadataHandling).

Gets or sets the XMP packet, or null if none.

public XmpProfile? XmpProfile { get; set; }

Property value

XmpProfile?

Methods

NameDescription
Clone()Creates an independent copy of this metadata.

Creates an independent copy of this metadata.

public ImageMetadata Clone()

Returns

ImageMetadata A new instance; mutable state is copied and immutable values are shared.