Class ImageExtensions
Extension methods for the Image type.
Inherited Members
Namespace: SixLabors.ImageSharp
Assembly: SixLabors.ImageSharp.dll
Syntax
public static class ImageExtensions
Methods
| Edit this page View SourceSave(Image, Stream, IImageFormat)
Writes the image to the given stream using the given image format.
Declaration
public static void Save(this Image source, Stream stream, IImageFormat format)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The source image. |
| Stream | stream | The stream to save the image to. |
| IImageFormat | format | The format to save the image in. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The stream is null. |
| ArgumentNullException | The format is null. |
| NotSupportedException | The stream is not writable. |
| NotSupportedException | No encoder available for provided format. |
Save(Image, string)
Writes the image to the given file path using an encoder detected from the path.
Declaration
public static void Save(this Image source, string path)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The source image. |
| string | path | The file path to save the image to. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The path is null. |
| NotSupportedException | No encoder available for provided path. |
Save(Image, string, IImageEncoder)
Writes the image to the given file path using the given image encoder.
Declaration
public static void Save(this Image source, string path, IImageEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The source image. |
| string | path | The file path to save the image to. |
| IImageEncoder | encoder | The encoder to save the image with. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The path is null. |
| ArgumentNullException | The encoder is null. |
SaveAsBmp(Image, Stream)
Saves the image to the given stream with the Bmp format.
Declaration
public static void SaveAsBmp(this Image source, Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| Stream | stream | The stream to save the image to. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream is null. |
SaveAsBmp(Image, Stream, BmpEncoder)
Saves the image to the given stream with the Bmp format.
Declaration
public static void SaveAsBmp(this Image source, Stream stream, BmpEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| Stream | stream | The stream to save the image to. |
| BmpEncoder | encoder | The encoder to save the image with. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream is null. |
SaveAsBmp(Image, string)
Saves the image to the given stream with the Bmp format.
Declaration
public static void SaveAsBmp(this Image source, string path)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsBmp(Image, string, BmpEncoder)
Saves the image to the given stream with the Bmp format.
Declaration
public static void SaveAsBmp(this Image source, string path, BmpEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
| BmpEncoder | encoder | The encoder to save the image with. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsBmpAsync(Image, Stream, BmpEncoder, CancellationToken)
Saves the image to the given stream with the Bmp format.
Declaration
public static Task SaveAsBmpAsync(this Image source, Stream stream, BmpEncoder encoder, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| Stream | stream | The stream to save the image to. |
| BmpEncoder | encoder | The encoder to save the image with. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream is null. |
SaveAsBmpAsync(Image, Stream, CancellationToken)
Saves the image to the given stream with the Bmp format.
Declaration
public static Task SaveAsBmpAsync(this Image source, Stream stream, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| Stream | stream | The stream to save the image to. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream is null. |
SaveAsBmpAsync(Image, string)
Saves the image to the given stream with the Bmp format.
Declaration
public static Task SaveAsBmpAsync(this Image source, string path)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsBmpAsync(Image, string, BmpEncoder, CancellationToken)
Saves the image to the given stream with the Bmp format.
Declaration
public static Task SaveAsBmpAsync(this Image source, string path, BmpEncoder encoder, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
| BmpEncoder | encoder | The encoder to save the image with. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsBmpAsync(Image, string, CancellationToken)
Saves the image to the given stream with the Bmp format.
Declaration
public static Task SaveAsBmpAsync(this Image source, string path, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsGif(Image, Stream)
Saves the image to the given stream with the Gif format.
Declaration
public static void SaveAsGif(this Image source, Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| Stream | stream | The stream to save the image to. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream is null. |
SaveAsGif(Image, Stream, GifEncoder)
Saves the image to the given stream with the Gif format.
Declaration
public static void SaveAsGif(this Image source, Stream stream, GifEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| Stream | stream | The stream to save the image to. |
| GifEncoder | encoder | The encoder to save the image with. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream is null. |
SaveAsGif(Image, string)
Saves the image to the given stream with the Gif format.
Declaration
public static void SaveAsGif(this Image source, string path)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsGif(Image, string, GifEncoder)
Saves the image to the given stream with the Gif format.
Declaration
public static void SaveAsGif(this Image source, string path, GifEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
| GifEncoder | encoder | The encoder to save the image with. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsGifAsync(Image, Stream, GifEncoder, CancellationToken)
Saves the image to the given stream with the Gif format.
Declaration
public static Task SaveAsGifAsync(this Image source, Stream stream, GifEncoder encoder, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| Stream | stream | The stream to save the image to. |
| GifEncoder | encoder | The encoder to save the image with. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream is null. |
SaveAsGifAsync(Image, Stream, CancellationToken)
Saves the image to the given stream with the Gif format.
Declaration
public static Task SaveAsGifAsync(this Image source, Stream stream, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| Stream | stream | The stream to save the image to. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream is null. |
SaveAsGifAsync(Image, string)
Saves the image to the given stream with the Gif format.
Declaration
public static Task SaveAsGifAsync(this Image source, string path)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsGifAsync(Image, string, GifEncoder, CancellationToken)
Saves the image to the given stream with the Gif format.
Declaration
public static Task SaveAsGifAsync(this Image source, string path, GifEncoder encoder, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
| GifEncoder | encoder | The encoder to save the image with. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsGifAsync(Image, string, CancellationToken)
Saves the image to the given stream with the Gif format.
Declaration
public static Task SaveAsGifAsync(this Image source, string path, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsJpeg(Image, Stream)
Saves the image to the given stream with the Jpeg format.
Declaration
public static void SaveAsJpeg(this Image source, Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| Stream | stream | The stream to save the image to. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream is null. |
SaveAsJpeg(Image, Stream, JpegEncoder)
Saves the image to the given stream with the Jpeg format.
Declaration
public static void SaveAsJpeg(this Image source, Stream stream, JpegEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| Stream | stream | The stream to save the image to. |
| JpegEncoder | encoder | The encoder to save the image with. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream is null. |
SaveAsJpeg(Image, string)
Saves the image to the given stream with the Jpeg format.
Declaration
public static void SaveAsJpeg(this Image source, string path)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsJpeg(Image, string, JpegEncoder)
Saves the image to the given stream with the Jpeg format.
Declaration
public static void SaveAsJpeg(this Image source, string path, JpegEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
| JpegEncoder | encoder | The encoder to save the image with. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsJpegAsync(Image, Stream, JpegEncoder, CancellationToken)
Saves the image to the given stream with the Jpeg format.
Declaration
public static Task SaveAsJpegAsync(this Image source, Stream stream, JpegEncoder encoder, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| Stream | stream | The stream to save the image to. |
| JpegEncoder | encoder | The encoder to save the image with. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream is null. |
SaveAsJpegAsync(Image, Stream, CancellationToken)
Saves the image to the given stream with the Jpeg format.
Declaration
public static Task SaveAsJpegAsync(this Image source, Stream stream, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| Stream | stream | The stream to save the image to. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream is null. |
SaveAsJpegAsync(Image, string)
Saves the image to the given stream with the Jpeg format.
Declaration
public static Task SaveAsJpegAsync(this Image source, string path)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsJpegAsync(Image, string, JpegEncoder, CancellationToken)
Saves the image to the given stream with the Jpeg format.
Declaration
public static Task SaveAsJpegAsync(this Image source, string path, JpegEncoder encoder, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
| JpegEncoder | encoder | The encoder to save the image with. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsJpegAsync(Image, string, CancellationToken)
Saves the image to the given stream with the Jpeg format.
Declaration
public static Task SaveAsJpegAsync(this Image source, string path, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsPbm(Image, Stream)
Saves the image to the given stream with the Pbm format.
Declaration
public static void SaveAsPbm(this Image source, Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| Stream | stream | The stream to save the image to. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream is null. |
SaveAsPbm(Image, Stream, PbmEncoder)
Saves the image to the given stream with the Pbm format.
Declaration
public static void SaveAsPbm(this Image source, Stream stream, PbmEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| Stream | stream | The stream to save the image to. |
| PbmEncoder | encoder | The encoder to save the image with. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream is null. |
SaveAsPbm(Image, string)
Saves the image to the given stream with the Pbm format.
Declaration
public static void SaveAsPbm(this Image source, string path)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsPbm(Image, string, PbmEncoder)
Saves the image to the given stream with the Pbm format.
Declaration
public static void SaveAsPbm(this Image source, string path, PbmEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
| PbmEncoder | encoder | The encoder to save the image with. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsPbmAsync(Image, Stream, PbmEncoder, CancellationToken)
Saves the image to the given stream with the Pbm format.
Declaration
public static Task SaveAsPbmAsync(this Image source, Stream stream, PbmEncoder encoder, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| Stream | stream | The stream to save the image to. |
| PbmEncoder | encoder | The encoder to save the image with. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream is null. |
SaveAsPbmAsync(Image, Stream, CancellationToken)
Saves the image to the given stream with the Pbm format.
Declaration
public static Task SaveAsPbmAsync(this Image source, Stream stream, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| Stream | stream | The stream to save the image to. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream is null. |
SaveAsPbmAsync(Image, string)
Saves the image to the given stream with the Pbm format.
Declaration
public static Task SaveAsPbmAsync(this Image source, string path)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsPbmAsync(Image, string, PbmEncoder, CancellationToken)
Saves the image to the given stream with the Pbm format.
Declaration
public static Task SaveAsPbmAsync(this Image source, string path, PbmEncoder encoder, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
| PbmEncoder | encoder | The encoder to save the image with. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsPbmAsync(Image, string, CancellationToken)
Saves the image to the given stream with the Pbm format.
Declaration
public static Task SaveAsPbmAsync(this Image source, string path, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsPng(Image, Stream)
Saves the image to the given stream with the Png format.
Declaration
public static void SaveAsPng(this Image source, Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| Stream | stream | The stream to save the image to. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream is null. |
SaveAsPng(Image, Stream, PngEncoder)
Saves the image to the given stream with the Png format.
Declaration
public static void SaveAsPng(this Image source, Stream stream, PngEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| Stream | stream | The stream to save the image to. |
| PngEncoder | encoder | The encoder to save the image with. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream is null. |
SaveAsPng(Image, string)
Saves the image to the given stream with the Png format.
Declaration
public static void SaveAsPng(this Image source, string path)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsPng(Image, string, PngEncoder)
Saves the image to the given stream with the Png format.
Declaration
public static void SaveAsPng(this Image source, string path, PngEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
| PngEncoder | encoder | The encoder to save the image with. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsPngAsync(Image, Stream, PngEncoder, CancellationToken)
Saves the image to the given stream with the Png format.
Declaration
public static Task SaveAsPngAsync(this Image source, Stream stream, PngEncoder encoder, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| Stream | stream | The stream to save the image to. |
| PngEncoder | encoder | The encoder to save the image with. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream is null. |
SaveAsPngAsync(Image, Stream, CancellationToken)
Saves the image to the given stream with the Png format.
Declaration
public static Task SaveAsPngAsync(this Image source, Stream stream, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| Stream | stream | The stream to save the image to. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream is null. |
SaveAsPngAsync(Image, string)
Saves the image to the given stream with the Png format.
Declaration
public static Task SaveAsPngAsync(this Image source, string path)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsPngAsync(Image, string, PngEncoder, CancellationToken)
Saves the image to the given stream with the Png format.
Declaration
public static Task SaveAsPngAsync(this Image source, string path, PngEncoder encoder, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
| PngEncoder | encoder | The encoder to save the image with. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsPngAsync(Image, string, CancellationToken)
Saves the image to the given stream with the Png format.
Declaration
public static Task SaveAsPngAsync(this Image source, string path, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsQoi(Image, Stream)
Saves the image to the given stream with the Qoi format.
Declaration
public static void SaveAsQoi(this Image source, Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| Stream | stream | The stream to save the image to. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream is null. |
SaveAsQoi(Image, Stream, QoiEncoder)
Saves the image to the given stream with the Qoi format.
Declaration
public static void SaveAsQoi(this Image source, Stream stream, QoiEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| Stream | stream | The stream to save the image to. |
| QoiEncoder | encoder | The encoder to save the image with. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream is null. |
SaveAsQoi(Image, string)
Saves the image to the given stream with the Qoi format.
Declaration
public static void SaveAsQoi(this Image source, string path)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsQoi(Image, string, QoiEncoder)
Saves the image to the given stream with the Qoi format.
Declaration
public static void SaveAsQoi(this Image source, string path, QoiEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
| QoiEncoder | encoder | The encoder to save the image with. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsQoiAsync(Image, Stream, QoiEncoder, CancellationToken)
Saves the image to the given stream with the Qoi format.
Declaration
public static Task SaveAsQoiAsync(this Image source, Stream stream, QoiEncoder encoder, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| Stream | stream | The stream to save the image to. |
| QoiEncoder | encoder | The encoder to save the image with. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream is null. |
SaveAsQoiAsync(Image, Stream, CancellationToken)
Saves the image to the given stream with the Qoi format.
Declaration
public static Task SaveAsQoiAsync(this Image source, Stream stream, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| Stream | stream | The stream to save the image to. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream is null. |
SaveAsQoiAsync(Image, string)
Saves the image to the given stream with the Qoi format.
Declaration
public static Task SaveAsQoiAsync(this Image source, string path)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsQoiAsync(Image, string, QoiEncoder, CancellationToken)
Saves the image to the given stream with the Qoi format.
Declaration
public static Task SaveAsQoiAsync(this Image source, string path, QoiEncoder encoder, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
| QoiEncoder | encoder | The encoder to save the image with. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsQoiAsync(Image, string, CancellationToken)
Saves the image to the given stream with the Qoi format.
Declaration
public static Task SaveAsQoiAsync(this Image source, string path, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsTga(Image, Stream)
Saves the image to the given stream with the Tga format.
Declaration
public static void SaveAsTga(this Image source, Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| Stream | stream | The stream to save the image to. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream is null. |
SaveAsTga(Image, Stream, TgaEncoder)
Saves the image to the given stream with the Tga format.
Declaration
public static void SaveAsTga(this Image source, Stream stream, TgaEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| Stream | stream | The stream to save the image to. |
| TgaEncoder | encoder | The encoder to save the image with. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream is null. |
SaveAsTga(Image, string)
Saves the image to the given stream with the Tga format.
Declaration
public static void SaveAsTga(this Image source, string path)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsTga(Image, string, TgaEncoder)
Saves the image to the given stream with the Tga format.
Declaration
public static void SaveAsTga(this Image source, string path, TgaEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
| TgaEncoder | encoder | The encoder to save the image with. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsTgaAsync(Image, Stream, TgaEncoder, CancellationToken)
Saves the image to the given stream with the Tga format.
Declaration
public static Task SaveAsTgaAsync(this Image source, Stream stream, TgaEncoder encoder, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| Stream | stream | The stream to save the image to. |
| TgaEncoder | encoder | The encoder to save the image with. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream is null. |
SaveAsTgaAsync(Image, Stream, CancellationToken)
Saves the image to the given stream with the Tga format.
Declaration
public static Task SaveAsTgaAsync(this Image source, Stream stream, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| Stream | stream | The stream to save the image to. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream is null. |
SaveAsTgaAsync(Image, string)
Saves the image to the given stream with the Tga format.
Declaration
public static Task SaveAsTgaAsync(this Image source, string path)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsTgaAsync(Image, string, TgaEncoder, CancellationToken)
Saves the image to the given stream with the Tga format.
Declaration
public static Task SaveAsTgaAsync(this Image source, string path, TgaEncoder encoder, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
| TgaEncoder | encoder | The encoder to save the image with. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsTgaAsync(Image, string, CancellationToken)
Saves the image to the given stream with the Tga format.
Declaration
public static Task SaveAsTgaAsync(this Image source, string path, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsTiff(Image, Stream)
Saves the image to the given stream with the Tiff format.
Declaration
public static void SaveAsTiff(this Image source, Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| Stream | stream | The stream to save the image to. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream is null. |
SaveAsTiff(Image, Stream, TiffEncoder)
Saves the image to the given stream with the Tiff format.
Declaration
public static void SaveAsTiff(this Image source, Stream stream, TiffEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| Stream | stream | The stream to save the image to. |
| TiffEncoder | encoder | The encoder to save the image with. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream is null. |
SaveAsTiff(Image, string)
Saves the image to the given stream with the Tiff format.
Declaration
public static void SaveAsTiff(this Image source, string path)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsTiff(Image, string, TiffEncoder)
Saves the image to the given stream with the Tiff format.
Declaration
public static void SaveAsTiff(this Image source, string path, TiffEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
| TiffEncoder | encoder | The encoder to save the image with. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsTiffAsync(Image, Stream, TiffEncoder, CancellationToken)
Saves the image to the given stream with the Tiff format.
Declaration
public static Task SaveAsTiffAsync(this Image source, Stream stream, TiffEncoder encoder, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| Stream | stream | The stream to save the image to. |
| TiffEncoder | encoder | The encoder to save the image with. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream is null. |
SaveAsTiffAsync(Image, Stream, CancellationToken)
Saves the image to the given stream with the Tiff format.
Declaration
public static Task SaveAsTiffAsync(this Image source, Stream stream, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| Stream | stream | The stream to save the image to. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream is null. |
SaveAsTiffAsync(Image, string)
Saves the image to the given stream with the Tiff format.
Declaration
public static Task SaveAsTiffAsync(this Image source, string path)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsTiffAsync(Image, string, TiffEncoder, CancellationToken)
Saves the image to the given stream with the Tiff format.
Declaration
public static Task SaveAsTiffAsync(this Image source, string path, TiffEncoder encoder, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
| TiffEncoder | encoder | The encoder to save the image with. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsTiffAsync(Image, string, CancellationToken)
Saves the image to the given stream with the Tiff format.
Declaration
public static Task SaveAsTiffAsync(this Image source, string path, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsWebp(Image, Stream)
Saves the image to the given stream with the Webp format.
Declaration
public static void SaveAsWebp(this Image source, Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| Stream | stream | The stream to save the image to. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream is null. |
SaveAsWebp(Image, Stream, WebpEncoder)
Saves the image to the given stream with the Webp format.
Declaration
public static void SaveAsWebp(this Image source, Stream stream, WebpEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| Stream | stream | The stream to save the image to. |
| WebpEncoder | encoder | The encoder to save the image with. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream is null. |
SaveAsWebp(Image, string)
Saves the image to the given stream with the Webp format.
Declaration
public static void SaveAsWebp(this Image source, string path)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsWebp(Image, string, WebpEncoder)
Saves the image to the given stream with the Webp format.
Declaration
public static void SaveAsWebp(this Image source, string path, WebpEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
| WebpEncoder | encoder | The encoder to save the image with. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsWebpAsync(Image, Stream, WebpEncoder, CancellationToken)
Saves the image to the given stream with the Webp format.
Declaration
public static Task SaveAsWebpAsync(this Image source, Stream stream, WebpEncoder encoder, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| Stream | stream | The stream to save the image to. |
| WebpEncoder | encoder | The encoder to save the image with. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream is null. |
SaveAsWebpAsync(Image, Stream, CancellationToken)
Saves the image to the given stream with the Webp format.
Declaration
public static Task SaveAsWebpAsync(this Image source, Stream stream, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| Stream | stream | The stream to save the image to. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream is null. |
SaveAsWebpAsync(Image, string)
Saves the image to the given stream with the Webp format.
Declaration
public static Task SaveAsWebpAsync(this Image source, string path)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsWebpAsync(Image, string, WebpEncoder, CancellationToken)
Saves the image to the given stream with the Webp format.
Declaration
public static Task SaveAsWebpAsync(this Image source, string path, WebpEncoder encoder, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
| WebpEncoder | encoder | The encoder to save the image with. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsWebpAsync(Image, string, CancellationToken)
Saves the image to the given stream with the Webp format.
Declaration
public static Task SaveAsWebpAsync(this Image source, string path, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image this method extends. |
| string | path | The file path to save the image to. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the path is null. |
SaveAsync(Image, Stream, IImageFormat, CancellationToken)
Writes the image to the given stream using the given image format.
Declaration
public static Task SaveAsync(this Image source, Stream stream, IImageFormat format, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The source image. |
| Stream | stream | The stream to save the image to. |
| IImageFormat | format | The format to save the image in. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The stream is null. |
| ArgumentNullException | The format is null. |
| NotSupportedException | The stream is not writable. |
| NotSupportedException | No encoder available for provided format. |
SaveAsync(Image, string, IImageEncoder, CancellationToken)
Writes the image to the given file path using the given image encoder.
Declaration
public static Task SaveAsync(this Image source, string path, IImageEncoder encoder, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The source image. |
| string | path | The file path to save the image to. |
| IImageEncoder | encoder | The encoder to save the image with. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The path is null. |
| ArgumentNullException | The encoder is null. |
SaveAsync(Image, string, CancellationToken)
Writes the image to the given file path using an encoder detected from the path.
Declaration
public static Task SaveAsync(this Image source, string path, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The source image. |
| string | path | The file path to save the image to. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The path is null. |
| NotSupportedException | No encoder available for provided path. |
ToBase64String(Image, IImageFormat)
Returns a Base64 encoded string from the given image. The result is prepended with a Data URI https://en.wikipedia.org/wiki/Data_URI_scheme
Declaration
public static string ToBase64String(this Image source, IImageFormat format)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The source image |
| IImageFormat | format | The format. |
Returns
| Type | Description |
|---|---|
| string | The string |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The format is null. |