Table of Contents

Class PngEncoder

Namespace
SixLabors.ImageSharp.Formats.Png
Assembly
SixLabors.ImageSharp.dll

Image encoder for writing image data to a stream in png format.

public class PngEncoder : QuantizingAnimatedImageEncoder, IImageEncoder, IQuantizingImageEncoder, IAnimatedImageEncoder
Inheritance
PngEncoder
Implements
Inherited Members

Properties

BitDepth

Gets the number of bits per sample or per palette index (not per pixel). Not all values are allowed for all ColorType values.

public PngBitDepth? BitDepth { get; init; }

Property Value

PngBitDepth?

ChunkFilter

Gets the chunk filter method. This allows to filter ancillary chunks.

public PngChunkFilter? ChunkFilter { get; init; }

Property Value

PngChunkFilter?

ColorType

Gets the color type.

public PngColorType? ColorType { get; init; }

Property Value

PngColorType?

CompressionLevel

Gets the compression level 1-9. Defaults to SixLabors.ImageSharp.Formats.Png.PngCompressionLevel.DefaultCompression.

public PngCompressionLevel CompressionLevel { get; init; }

Property Value

PngCompressionLevel

FilterMethod

Gets the filter method.

public PngFilterMethod? FilterMethod { get; init; }

Property Value

PngFilterMethod?

Gamma

Gets the gamma value, that will be written the image.

public float? Gamma { get; init; }

Property Value

float?

The gamma value of the image.

InterlaceMethod

Gets a value indicating whether this instance should write an Adam7 interlaced image.

public PngInterlaceMode? InterlaceMethod { get; init; }

Property Value

PngInterlaceMode?

TextCompressionThreshold

Gets the threshold of characters in text metadata, when compression should be used.

public int TextCompressionThreshold { get; init; }

Property Value

int

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.