ImageWriterOptions Class
Immutable options for Image.CreateWriter.
public sealed class ImageWriterOptionsRemarks
The writer takes a snapshot of these options when it is created: later changes to the ImageWriterOptions.Metadata or ImageWriterOptions.Animation instances passed here do not affect the writer.
Constructors
| Name | Description |
|---|---|
| ImageWriterOptions(Size) | Initializes a new instance of the ImageWriterOptions class. |
| ImageWriterOptions(int, int) | Initializes a new instance of the ImageWriterOptions class. |
ImageWriterOptions overloads
ImageWriterOptions(Size)
ImageWriterOptions.csInitializes a new instance of the ImageWriterOptions class.
public ImageWriterOptions(Size canvasSize)Parameters
canvasSizeSize- The size of every frame written. Must not be empty.
Exceptions
ArgumentOutOfRangeExceptioncanvasSizeis empty.
ImageWriterOptions(int, int)
ImageWriterOptions.csInitializes a new instance of the ImageWriterOptions class.
Parameters
widthint- The width of every frame written. Must be positive.
heightint- The height of every frame written. Must be positive.
Exceptions
ArgumentOutOfRangeExceptionwidthorheightis not positive.
Properties
| Name | Description |
|---|---|
| Animation | Gets the animation-wide settings (such as the number of plays), or null for defaults. When null and more than one frame or a poster frame is written, an infinitely looping animation is produced. The writer copies it when it is created. |
| CanvasSize | Gets the size of every frame written. |
| Configuration | Gets the configuration of the writer (resource limits, parallelism). Defaults to ImageConfiguration.Default. |
| Encoder | Gets the encoder and its settings. Required for stream outputs. For path outputs, null selects the encoder from the file extension, like Image.Save. |
| ExpectedFrameCount | Gets the number of displayed frames that will be written (excluding a poster frame), or null if unknown. PNG/APNG, AVIF and HEIC output require a known count; GIF supports an unknown count; JPEG output requires exactly one frame. ImageWriter<TPixel>.Complete fails if the actual count differs. |
| LeaveOpen | Gets a value indicating whether a caller-provided stream is left open when the writer is disposed. Defaults to true. Streams opened by the path overloads are always owned by the writer. |
| Metadata | Gets the image-wide metadata to write, or null to write none. The writer copies it when it is created. |
Animation
ImageWriterOptions.csGets the animation-wide settings (such as the number of plays), or null for defaults. When null and more than one frame or a poster frame is written, an infinitely looping animation is produced. The writer copies it when it is created.
public AnimationMetadata? Animation { get; init; }Property value
CanvasSize
ImageWriterOptions.csConfiguration
ImageWriterOptions.csGets the configuration of the writer (resource limits, parallelism). Defaults to ImageConfiguration.Default.
public ImageConfiguration Configuration { get; init; }Encoder
ImageWriterOptions.csGets the encoder and its settings. Required for stream outputs. For path outputs, null selects the encoder from the file extension, like Image.Save.
public ImageEncoder? Encoder { get; init; }Property value
ExpectedFrameCount
ImageWriterOptions.csGets the number of displayed frames that will be written (excluding a poster frame), or null if unknown. PNG/APNG, AVIF and HEIC output require a known count; GIF supports an unknown count; JPEG output requires exactly one frame. ImageWriter<TPixel>.Complete fails if the actual count differs.
public int? ExpectedFrameCount { get; init; }LeaveOpen
ImageWriterOptions.csMetadata
ImageWriterOptions.csGets the image-wide metadata to write, or null to write none. The writer copies it when it is created.
public ImageMetadata? Metadata { get; init; }