HeyRed.ImageSharp.Heif 2.1.3

dotnet add package HeyRed.ImageSharp.Heif --version 2.1.3                
NuGet\Install-Package HeyRed.ImageSharp.Heif -Version 2.1.3                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="HeyRed.ImageSharp.Heif" Version="2.1.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add HeyRed.ImageSharp.Heif --version 2.1.3                
#r "nuget: HeyRed.ImageSharp.Heif, 2.1.3"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install HeyRed.ImageSharp.Heif as a Cake Addin
#addin nuget:?package=HeyRed.ImageSharp.Heif&version=2.1.3

// Install HeyRed.ImageSharp.Heif as a Cake Tool
#tool nuget:?package=HeyRed.ImageSharp.Heif&version=2.1.3                

ImageSharp.Heif

HEIF/AVIF decoder for ImageSharp

🚧 WIP. Some features(like encoder) is not implemented.

Use libheif-sharp for all features provided by libheif.

Install

via NuGet:

PM> Install-Package HeyRed.ImageSharp.Heif

Native libs for x64 Linux and Windows:

PM> Install-Package LibHeif.Native

Separate native packages:

PM> Install-Package LibHeif.Native.win-x64
PM> Install-Package LibHeif.Native.linux-x64

Usage

using System.IO;

using SixLabors.ImageSharp;

using HeyRed.ImageSharp.Heif.Formats.Heif;
using HeyRed.ImageSharp.Heif.Formats.Avif;

var decoderOptions = new DecoderOptions()
{
    Configuration = new Configuration(
        new AvifConfigurationModule(), 
        new HeifConfigurationModule())
};

using var image = Image.Load(decoderOptions, "/path/to/image.avif"); // or image.heic

// Do something with image
...

Top level images

⚠️ Due to the ImageSharp limitations, decoding top level images with different sizes are not supported. ⚠️

Note: libheif have some limitations

By default DecodingMode set to PrimaryImage, but if you want decode all top level images see example listed below:

var decoderOptions = new HeifDecoderOptions
{
    DecodingMode = DecodingMode.TopLevelImages,
    // MaxFrames option is also supported
    GeneralOptions = new DecoderOptions
    {
        MaxFrames = 10,
    }
};

using var inputStream = File.OpenRead("/path/to/image.avif"); // or image.heic

using var image = HeifDecoder.Instance.Decode(decoderOptions, inputStream);

// Saves all frames
for (int i = 0; i < image.Frames.Count; i++)
{
    image.Frames
        .CloneFrame(i)
        .SaveAsJpeg($"frame{i}.jpg");
}

License

MIT

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on HeyRed.ImageSharp.Heif:

Repository Stars
Particle1904/DatasetHelpers
Dataset Helper program to automatically select, re scale and tag Datasets (composed of image and text) for Machine Learning training.
Version Downloads Last updated
2.1.3 251,281 10/12/2023
2.1.1 2,074 3/6/2023
2.1.0 241 3/5/2023
2.0.0 268 3/4/2023
1.0.0 5,134 11/16/2022
1.0.0-alpha.2 104 11/15/2022
1.0.0-alpha 109 11/15/2022