Table of Contents

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

Properties

ColorType

Gets the jpeg color for encoding.

public JpegColorType? ColorType { get; init; }

Property Value

JpegColorType?

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.

Progressive

Gets a value indicating whether progressive encoding is used.

public bool Progressive { get; init; }

Property Value

bool

ProgressiveScans

Gets number of scans per component for progressive encoding. Defaults to 4.

public int ProgressiveScans { get; init; }

Property Value

int

Remarks

Number of scans must be between 2 and 64. There is at least one scan for the DC coefficients and one for the remaining 63 AC coefficients.

Exceptions

ArgumentException

Progressive scans must be in [2..64] range.

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 75.

public int? Quality { get; init; }

Property Value

int?

Exceptions

ArgumentException

Quality factor must be in [1..100] range.

RestartInterval

Gets numbers of MCUs between restart markers. Defaults to 0.

public int RestartInterval { get; init; }

Property Value

int

Remarks

Currently supported in progressive encoding only.

Exceptions

ArgumentException

Restart interval must be in [0..65535] 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 Stream

The Stream to encode the image data to.

cancellationToken CancellationToken

The 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.