Table of Contents

Class AvifLayer

Namespace
Egami.Formats.Avif
Assembly
Egami.dll

One layer of a progressive AVIF image (Layers): its quality and its scale.

public sealed record AvifLayer : IEquatable<AvifLayer>
Inheritance
AvifLayer
Implements
Inherited Members

Examples

// A progressive file: a small first layer a viewer can show early, then the image (as avifenc --progressive writes it).
duck.Save("duck-progressive.avif", new AvifWriterOptions { Quality = 60, Progressive = true });

// Or up to four layers, each with its own quality and size; the last is the image at full size.
duck.Save("duck-layers.avif", new AvifWriterOptions
{
    Layers = [new AvifLayer { Quality = 20, Scale = 0.5 }, new AvifLayer { Quality = 45 }, new AvifLayer { Quality = 75 }],
});

// Load gives the best layer; AvifReaderOptions.Layer picks another, at full size.
using Raster best = Raster.Load("duck-layers.avif");
IReadOnlyList<Size> layers = ((AvifDetails)best.Metadata.FormatDetails!).Layers;   // 160x120, 320x240, 320x240
using Raster first = Raster.Load("duck-layers.avif", options: new AvifReaderOptions { Layer = 0 });

Properties

Quality

Gets the layer's quality, 0 to 100 on Quality's scale. Defaults to 60.

public int Quality { get; init; }

Property Value

int

Exceptions

ArgumentOutOfRangeException

The value is outside 0 to 100.

Scale

Gets the layer's size as a part of the image's, above 0 up to 1 (the default), as avifenc --scaling-mode sets it: a layer at 0.5 is coded at half the width and height and shown scaled up. A layer of another size than the one before it is coded on its own rather than from it.

public double Scale { get; init; }

Property Value

double

Exceptions

ArgumentOutOfRangeException

The value is not above 0 and at most 1.