ImageResourceLimits Class
Immutable resource limits applied while decoding, processing and encoding images.
public sealed class ImageResourceLimitsRemarks
Every limit must be positive; there is no "zero means unlimited" convention. To effectively disable a limit, set it to the maximum value of its type. Exceeding a limit throws an ImageResourceLimitException; it is never turned into a silently truncated result.
Limits are safety bounds, not a selection mechanism: use ImageDecodeOptions.FrameLimit to deliberately decode only a prefix of an animation. Allocation limits apply to library-controlled buffers within an allocation scope (an image and the operation working on it); they are not a process-wide memory cap.
Constructors
| Name | Description |
|---|---|
| ImageResourceLimits() |
ImageResourceLimits()
ImageResourceLimits.cspublic ImageResourceLimits()No documentation is available.
Properties
| Name | Description |
|---|---|
| Default | Gets the default limits. |
| MaxEncodedBytes | Gets the maximum number of encoded bytes read from one input. Defaults to ImageResourceLimits.DefaultMaxEncodedBytes. |
| MaxFontBytes | Gets the maximum number of bytes a font keeps in memory: the size of a font file, once decompressed when it is a WOFF or WOFF2 file. Defaults to ImageResourceLimits.DefaultMaxFontBytes. |
| MaxFontCollectionFaces | Gets the maximum number of fonts of a font collection (a TTC file). Defaults to ImageResourceLimits.DefaultMaxFontCollectionFaces. |
| MaxFramePixels | Gets the maximum number of pixels of one displayed frame. Defaults to ImageResourceLimits.DefaultMaxFramePixels. |
| MaxFrames | Gets the maximum number of frames (displayed frames plus poster frame) processed from one input. Defaults to ImageResourceLimits.DefaultMaxFrames. |
| MaxGlyphComplexity | Gets the maximum number of elementary operations spent to produce one glyph: the points of its outline, the components of a composite glyph, the operators of a charstring, the nodes of a color glyph. Defaults to ImageResourceLimits.DefaultMaxGlyphComplexity. |
| MaxHeight | Gets the maximum canvas height, in pixels. Defaults to ImageResourceLimits.DefaultMaxDimension. |
| MaxLiveAllocationBytes | Gets the maximum number of live library-controlled bytes per allocation scope. Defaults to ImageResourceLimits.DefaultMaxLiveAllocationBytes. |
| MaxMetadataBytes | Gets the maximum number of decompressed or retained metadata bytes (profiles, text, EXIF, XMP) per input. Defaults to ImageResourceLimits.DefaultMaxMetadataBytes. |
| MaxTextGlyphs | Gets the maximum number of glyphs of a text layout. Defaults to ImageResourceLimits.DefaultMaxTextGlyphs. |
| MaxTextLength | Gets the maximum length of a text that is laid out, in UTF-16 code units. Defaults to ImageResourceLimits.DefaultMaxTextLength. |
| MaxTextLines | Gets the maximum number of lines of a text layout. Defaults to ImageResourceLimits.DefaultMaxTextLines. |
| MaxTotalPixels | Gets the maximum cumulative number of displayed pixels produced while reading one input. Defaults to ImageResourceLimits.DefaultMaxTotalPixels. |
| MaxWidth | Gets the maximum canvas width, in pixels. Defaults to ImageResourceLimits.DefaultMaxDimension. |
Default
ImageResourceLimits.csMaxEncodedBytes
ImageResourceLimits.csGets the maximum number of encoded bytes read from one input. Defaults to ImageResourceLimits.DefaultMaxEncodedBytes.
public long MaxEncodedBytes { get; init; }Property value
Exceptions
ArgumentOutOfRangeException- The value is not positive.
Remarks
Synchronous TIFF, ICO, CUR and ANI loads from a path or seekable stream charge cumulative reads, including repeated ranges, not the file length. Span, non-seekable and asynchronous loads of these formats charge the whole input once.
MaxFontBytes
ImageResourceLimits.csGets the maximum number of bytes a font keeps in memory: the size of a font file, once decompressed when it is a WOFF or WOFF2 file. Defaults to ImageResourceLimits.DefaultMaxFontBytes.
public long MaxFontBytes { get; init; }Property value
Exceptions
ArgumentOutOfRangeException- The value is not positive.
Remarks
The bytes read from the input are bounded by ImageResourceLimits.MaxEncodedBytes, as for an image.
MaxFontCollectionFaces
ImageResourceLimits.csGets the maximum number of fonts of a font collection (a TTC file). Defaults to ImageResourceLimits.DefaultMaxFontCollectionFaces.
public int MaxFontCollectionFaces { get; init; }Property value
Exceptions
ArgumentOutOfRangeException- The value is not positive.
Remarks
Every font of a collection is read when the collection is loaded, and the fonts can share their tables: this limit bounds that work.
MaxFramePixels
ImageResourceLimits.csGets the maximum number of pixels of one displayed frame. Defaults to ImageResourceLimits.DefaultMaxFramePixels.
public long MaxFramePixels { get; init; }MaxFrames
ImageResourceLimits.csGets the maximum number of frames (displayed frames plus poster frame) processed from one input. Defaults to ImageResourceLimits.DefaultMaxFrames.
public int MaxFrames { get; init; }MaxGlyphComplexity
ImageResourceLimits.csGets the maximum number of elementary operations spent to produce one glyph: the points of its outline, the components of a composite glyph, the operators of a charstring, the nodes of a color glyph. Defaults to ImageResourceLimits.DefaultMaxGlyphComplexity.
public long MaxGlyphComplexity { get; init; }Property value
Exceptions
ArgumentOutOfRangeException- The value is not positive.
Remarks
A font can describe, in a few bytes, a glyph whose outline is exponentially large (glyphs made of glyphs made of glyphs). This limit bounds the work and the memory a hostile font can ask for.
MaxHeight
ImageResourceLimits.csGets the maximum canvas height, in pixels. Defaults to ImageResourceLimits.DefaultMaxDimension.
public int MaxHeight { get; init; }MaxLiveAllocationBytes
ImageResourceLimits.csGets the maximum number of live library-controlled bytes per allocation scope. Defaults to ImageResourceLimits.DefaultMaxLiveAllocationBytes.
public long MaxLiveAllocationBytes { get; init; }MaxMetadataBytes
ImageResourceLimits.csGets the maximum number of decompressed or retained metadata bytes (profiles, text, EXIF, XMP) per input. Defaults to ImageResourceLimits.DefaultMaxMetadataBytes.
public long MaxMetadataBytes { get; init; }MaxTextGlyphs
ImageResourceLimits.csGets the maximum number of glyphs of a text layout. Defaults to ImageResourceLimits.DefaultMaxTextGlyphs.
public long MaxTextGlyphs { get; init; }Property value
Exceptions
ArgumentOutOfRangeException- The value is not positive.
Remarks
A layout keeps the identifier and the position of each of its glyphs: this limit bounds the memory of a layout and the work of drawing it.
MaxTextLength
ImageResourceLimits.csGets the maximum length of a text that is laid out, in UTF-16 code units. Defaults to ImageResourceLimits.DefaultMaxTextLength.
public long MaxTextLength { get; init; }Property value
Exceptions
ArgumentOutOfRangeException- The value is not positive.
Remarks
The limits of a text layout are those of the configuration its font was loaded with.
MaxTextLines
ImageResourceLimits.csGets the maximum number of lines of a text layout. Defaults to ImageResourceLimits.DefaultMaxTextLines.
public int MaxTextLines { get; init; }Property value
Exceptions
ArgumentOutOfRangeException- The value is not positive.
Remarks
A text that needs more lines is an error; TextLayoutOptions.MaxLines is what cuts a text at a number of lines.
MaxTotalPixels
ImageResourceLimits.csGets the maximum cumulative number of displayed pixels produced while reading one input. Defaults to ImageResourceLimits.DefaultMaxTotalPixels.
public long MaxTotalPixels { get; init; }MaxWidth
ImageResourceLimits.csGets the maximum canvas width, in pixels. Defaults to ImageResourceLimits.DefaultMaxDimension.
public int MaxWidth { get; init; }Constants
| Name | Description |
|---|---|
| DefaultMaxDimension | The default maximum canvas width and height, in pixels (32,768). |
| DefaultMaxEncodedBytes | The default maximum number of encoded bytes read from one input (256 MiB). |
| DefaultMaxFontBytes | The default maximum number of bytes a font keeps in memory (256 MiB). |
| DefaultMaxFontCollectionFaces | The default maximum number of fonts of a font collection (1,024). |
| DefaultMaxFramePixels | The default maximum number of pixels of one displayed frame (100,000,000). |
| DefaultMaxFrames | The default maximum number of frames processed from one input (1,000). |
| DefaultMaxGlyphComplexity | The default maximum number of elementary operations to produce one glyph (1,000,000). |
| DefaultMaxLiveAllocationBytes | The default maximum number of live library-controlled bytes per allocation scope (512 MiB). |
| DefaultMaxMetadataBytes | The default maximum number of decompressed or retained metadata bytes (16 MiB). |
| DefaultMaxTextGlyphs | The default maximum number of glyphs of a text layout (1,000,000). |
| DefaultMaxTextLength | The default maximum length of a text that is laid out, in UTF-16 code units (1,000,000). |
| DefaultMaxTextLines | The default maximum number of lines of a text layout (100,000). |
| DefaultMaxTotalPixels | The default maximum cumulative number of displayed pixels produced while reading one input (1,000,000,000). |
DefaultMaxDimension
The default maximum canvas width and height, in pixels (32,768).
public const int DefaultMaxDimension = 32768DefaultMaxEncodedBytes
The default maximum number of encoded bytes read from one input (256 MiB).
public const long DefaultMaxEncodedBytes = 268435456LDefaultMaxFontBytes
The default maximum number of bytes a font keeps in memory (256 MiB).
public const long DefaultMaxFontBytes = 268435456LDefaultMaxFontCollectionFaces
The default maximum number of fonts of a font collection (1,024).
public const int DefaultMaxFontCollectionFaces = 1024DefaultMaxFramePixels
The default maximum number of pixels of one displayed frame (100,000,000).
public const long DefaultMaxFramePixels = 100000000LDefaultMaxFrames
The default maximum number of frames processed from one input (1,000).
public const int DefaultMaxFrames = 1000DefaultMaxGlyphComplexity
The default maximum number of elementary operations to produce one glyph (1,000,000).
public const long DefaultMaxGlyphComplexity = 1000000LDefaultMaxLiveAllocationBytes
The default maximum number of live library-controlled bytes per allocation scope (512 MiB).
public const long DefaultMaxLiveAllocationBytes = 536870912LDefaultMaxMetadataBytes
The default maximum number of decompressed or retained metadata bytes (16 MiB).
public const long DefaultMaxMetadataBytes = 16777216LDefaultMaxTextGlyphs
The default maximum number of glyphs of a text layout (1,000,000).
public const long DefaultMaxTextGlyphs = 1000000LDefaultMaxTextLength
The default maximum length of a text that is laid out, in UTF-16 code units (1,000,000).
public const long DefaultMaxTextLength = 1000000LDefaultMaxTextLines
The default maximum number of lines of a text layout (100,000).
public const int DefaultMaxTextLines = 100000DefaultMaxTotalPixels
The default maximum cumulative number of displayed pixels produced while reading one input (1,000,000,000).
public const long DefaultMaxTotalPixels = 1000000000L