Class ImageDecodeLimits
Resource limits applied while decoding untrusted images. A decoder never allocates on the strength of a size read from the file unless it is within these limits; a file that exceeds them fails with InvalidDataException.
Inherited Members
Namespace: DRIT.Drawing.Imaging
Assembly: DRIT.Drawing.dll
Syntax
public sealed class ImageDecodeLimits
Remarks
Default applies to every decode that does not pass its own limits. Applications that open large trusted files (scans, maps, panoramas) can raise it once at start-up; services that decode uploads can lower it, or pass a stricter instance per call to FromStream(Stream, ImageDecodeLimits).
Constructors
ImageDecodeLimits(long, int, long, long, int, long)
Creates a set of limits. Every argument defaults to the library's standard value.
Declaration
public ImageDecodeLimits(long maxPixels = 100000000, int maxDimension = 100000, long maxDecodedBytes = 1073741824, long maxSourceBytes = 536870912, int maxFrameCount = 1024, long maxAnimationBytes = 536870912)
Parameters
| Type | Name | Description |
|---|---|---|
| long | maxPixels | Largest number of pixels in one image or frame. |
| int | maxDimension | Largest width or height in pixels. |
| long | maxDecodedBytes | Largest single buffer a decoder may allocate for decoded or intermediate data. |
| long | maxSourceBytes | Largest input (or compressed image data) a decoder will read. |
| int | maxFrameCount | Largest number of frames in an animation. |
| long | maxAnimationBytes | Largest total of decoded pixel data over all frames of one animation. |
Remarks
Default applies to every decode that does not pass its own limits. Applications that open large trusted files (scans, maps, panoramas) can raise it once at start-up; services that decode uploads can lower it, or pass a stricter instance per call to FromStream(Stream, ImageDecodeLimits).
Properties
Default
The limits used when a decode does not specify its own. Settable once at application start-up.
Declaration
public static ImageDecodeLimits Default { get; set; }
Property Value
| Type | Description |
|---|---|
| ImageDecodeLimits |
Remarks
Default applies to every decode that does not pass its own limits. Applications that open large trusted files (scans, maps, panoramas) can raise it once at start-up; services that decode uploads can lower it, or pass a stricter instance per call to FromStream(Stream, ImageDecodeLimits).
MaxAnimationBytes
Largest total decoded size of all frames of one animation in bytes (default 512 MiB).
Declaration
public long MaxAnimationBytes { get; }
Property Value
| Type | Description |
|---|---|
| long |
Remarks
Default applies to every decode that does not pass its own limits. Applications that open large trusted files (scans, maps, panoramas) can raise it once at start-up; services that decode uploads can lower it, or pass a stricter instance per call to FromStream(Stream, ImageDecodeLimits).
MaxDecodedBytes
Largest single decoded or intermediate buffer in bytes (default 1 GiB; never more than 2 GiB).
Declaration
public long MaxDecodedBytes { get; }
Property Value
| Type | Description |
|---|---|
| long |
Remarks
Default applies to every decode that does not pass its own limits. Applications that open large trusted files (scans, maps, panoramas) can raise it once at start-up; services that decode uploads can lower it, or pass a stricter instance per call to FromStream(Stream, ImageDecodeLimits).
MaxDimension
Largest width or height in pixels (default 100 000).
Declaration
public int MaxDimension { get; }
Property Value
| Type | Description |
|---|---|
| int |
Remarks
Default applies to every decode that does not pass its own limits. Applications that open large trusted files (scans, maps, panoramas) can raise it once at start-up; services that decode uploads can lower it, or pass a stricter instance per call to FromStream(Stream, ImageDecodeLimits).
MaxFrameCount
Largest number of animation frames (default 1024).
Declaration
public int MaxFrameCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
Remarks
Default applies to every decode that does not pass its own limits. Applications that open large trusted files (scans, maps, panoramas) can raise it once at start-up; services that decode uploads can lower it, or pass a stricter instance per call to FromStream(Stream, ImageDecodeLimits).
MaxPixels
Largest number of pixels in one image or frame (default 100 million).
Declaration
public long MaxPixels { get; }
Property Value
| Type | Description |
|---|---|
| long |
Remarks
Default applies to every decode that does not pass its own limits. Applications that open large trusted files (scans, maps, panoramas) can raise it once at start-up; services that decode uploads can lower it, or pass a stricter instance per call to FromStream(Stream, ImageDecodeLimits).
MaxSourceBytes
Largest input or compressed image data in bytes (default 512 MiB).
Declaration
public long MaxSourceBytes { get; }
Property Value
| Type | Description |
|---|---|
| long |
Remarks
Default applies to every decode that does not pass its own limits. Applications that open large trusted files (scans, maps, panoramas) can raise it once at start-up; services that decode uploads can lower it, or pass a stricter instance per call to FromStream(Stream, ImageDecodeLimits).