Class JpegEncoder
- Namespace
- SixLabors.ImageSharp.Formats.Jpeg
- Assembly
- SixLabors.ImageSharp.dll
Encoder for writing the data image to a stream in jpeg format.
public sealed class JpegEncoder : ImageEncoder, IImageEncoder
- Inheritance
-
JpegEncoder
- Implements
- Inherited Members
Constructors
JpegEncoder()
public JpegEncoder()
Properties
ColorType
Gets the jpeg color for encoding.
public JpegEncodingColor? ColorType { get; init; }
Property Value
Interleaved
Gets the component encoding mode.
public bool? Interleaved { get; init; }
Property Value
- bool?
Remarks
Interleaved encoding mode encodes all color components in a single scan. Non-interleaved encoding mode encodes each color component in a separate scan.
Quality
Gets the quality, that will be used to encode the image. Quality
index must be between 1 and 100 (compression from max to min).
Defaults to
public int? Quality { get; init; }
Property Value
- int?
Exceptions
- ArgumentException
Quality factor must be in [1..100] range.
Methods
Encode<TPixel>(Image<TPixel>, Stream, CancellationToken)
Encodes the image to the specified stream from the Image<TPixel>.
protected override void Encode<TPixel>(Image<TPixel> image, Stream stream, CancellationToken cancellationToken) where TPixel : unmanaged, IPixel<TPixel>
Parameters
image
Image<TPixel>The Image<TPixel> to encode from.
stream
StreamThe Stream to encode the image data to.
cancellationToken
CancellationTokenThe token to monitor for cancellation requests.
Type Parameters
TPixel
The pixel format.
Remarks
This method is designed to support the ImageSharp internal infrastructure and is not recommended for direct use.