Class ImageEncoder
Acts as a base class for image encoders. Types that inherit this encoder are required to implement cancellable synchronous encoding operations only.
Inheritance
Implements
Inherited Members
Namespace: SixLabors.ImageSharp.Formats
Assembly: SixLabors.ImageSharp.dll
Syntax
public abstract class ImageEncoder : IImageEncoder
Properties
| Edit this page View SourceSkipMetadata
Gets a value indicating whether to ignore decoded metadata when encoding.
Declaration
public bool SkipMetadata { get; init; }
Property Value
Type | Description |
---|---|
bool |
Methods
| Edit this page View SourceEncodeAsync<TPixel>(Image<TPixel>, Stream, CancellationToken)
Encodes the image to the specified stream from the Image<TPixel>.
Declaration
public Task EncodeAsync<TPixel>(Image<TPixel> image, Stream stream, CancellationToken cancellationToken = default) where TPixel : unmanaged, IPixel<TPixel>
Parameters
Type | Name | Description |
---|---|---|
Image<TPixel> | image | The Image<TPixel> to encode from. |
Stream | stream | The Stream to encode the image data to. |
CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
Type | Description |
---|---|
Task | A Task representing the asynchronous operation. |
Type Parameters
Name | Description |
---|---|
TPixel | The pixel format. |
Encode<TPixel>(Image<TPixel>, Stream)
Encodes the image to the specified stream from the Image<TPixel>.
Declaration
public void Encode<TPixel>(Image<TPixel> image, Stream stream) where TPixel : unmanaged, IPixel<TPixel>
Parameters
Type | Name | Description |
---|---|---|
Image<TPixel> | image | The Image<TPixel> to encode from. |
Stream | stream | The Stream to encode the image data to. |
Type Parameters
Name | Description |
---|---|
TPixel | The pixel format. |
Encode<TPixel>(Image<TPixel>, Stream, CancellationToken)
Encodes the image to the specified stream from the Image<TPixel>.
Declaration
protected abstract void Encode<TPixel>(Image<TPixel> image, Stream stream, CancellationToken cancellationToken) where TPixel : unmanaged, IPixel<TPixel>
Parameters
Type | Name | Description |
---|---|---|
Image<TPixel> | image | The Image<TPixel> to encode from. |
Stream | stream | The Stream to encode the image data to. |
CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Type Parameters
Name | Description |
---|---|
TPixel | The pixel format. |
Remarks
This method is designed to support the ImageSharp internal infrastructure and is not recommended for direct use.