Openize.Heic 24.6.0

dotnet add package Openize.Heic --version 24.6.0
NuGet\Install-Package Openize.Heic -Version 24.6.0
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="Openize.Heic" Version="24.6.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Openize.Heic --version 24.6.0
#r "nuget: Openize.Heic, 24.6.0"
#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 Openize.Heic as a Cake Addin
#addin nuget:?package=Openize.Heic&version=24.6.0

// Install Openize.Heic as a Cake Tool
#tool nuget:?package=Openize.Heic&version=24.6.0

Openize.Heic

Openize.Heic is an open source SDK implementing the ISO/IEC 23008-12:2017 HEIF file format decoder.

It is written from scratch and has a plain C# API to enable a simple integration into other software.

Supported features

Openize.Heic has support for:

  • HEIC coded static images;
    • I slices;
    • 4:2:0, 4:2:2 and 4:4:4 chroma subsampling.
  • HEIC coded animations that use several I‑slices;
  • multiple images in a file;
  • alpha channels, depth maps, thumbnails, auxiliary images;
  • correct color transform according to embedded color profiles;
  • image transformations (crop, mirror, rotate), overlay images.

Openize.Heic doesn't support:

  • HDR images;
  • reading EXIF and XMP metadata;
  • color transform according to EXIF contained color profiles;
  • HEIC coded animations that use P and B‑slices;
  • deblocking filter.

New features & enhancements in version 24.6:

  • HeicImage changes:
    • property "Frames" changed and grants access only to public frames;
    • added new property "AllFrames", it grants access to all frames.
  • HeicImageFrame changes:
    • added property "IsHidden" that indicates if the frame is marked as hidden;
    • added property "IsImage" that indicates if the frame contains image data;
    • added property "AuxiliaryReferenceType" that indicates the type of auxiliary reference layer in case the frame type is auxiliary;
    • added method "GetTextData()" that grants access to text data for mime frame types;
    • methods GetByteArray() and GetInt32Array() now return null for non-image frames.

Usage examples

Read .heic file to int array with Argb32 data

using (var fs = new FileStream("filename.heic", FileMode.Open))
{
    HeicImage image = HeicImage.Load(fs);
    int[] pixels = image.GetInt32Array(Heic.Decoder.PixelFormat.Argb32);
}

Convert .heic file to .png

using (var fs = new FileStream("filename.heic", FileMode.Open))
{
    HeicImage image = HeicImage.Load(fs);
     
    var pixels = image.GetByteArray(Heic.Decoder.PixelFormat.Bgra32);
    var width = (int)image.Width;
    var height = (int)image.Height;
     
    var wbitmap = new WriteableBitmap(width, height, 72, 72, PixelFormats.Bgra32, null);
    var rect = new Int32Rect(0, 0, width, height);
    wbitmap.WritePixels(rect, pixels, 4 * width, 0);
    
    using FileStream saveStream = new FileStream("output.png", FileMode.OpenOrCreate);
    PngBitmapEncoder encoder = new PngBitmapEncoder();
    encoder.Frames.Add(BitmapFrame.Create(wbitmap));
    encoder.Save(saveStream);
}

Convert .heic file to .jpg

using (var fs = new FileStream("filename.heic", FileMode.Open))
{
    HeicImage image = HeicImage.Load(fs);
     
    var pixels = image.GetByteArray(Heic.Decoder.PixelFormat.Bgra32);
    var width = (int)image.Width;
    var height = (int)image.Height;
     
    var wbitmap = new WriteableBitmap(width, height, 72, 72, PixelFormats.Bgra32, null);
    var rect = new Int32Rect(0, 0, width, height);
    wbitmap.WritePixels(rect, pixels, 4 * width, 0);
    
    using FileStream saveStream = new FileStream("output.jpg", FileMode.OpenOrCreate);
    JpegBitmapEncoder encoder = new JpegBitmapEncoder();
    encoder.Frames.Add(BitmapFrame.Create(wbitmap));
    encoder.Save(saveStream);
}

Convert .heic collection to a set of .png files

using (var fs = new FileStream("filename.heic", FileMode.Open))
{
    HeicImage image = HeicImage.Load(fs);

    foreach (var key in image.Frames.Keys)
    {
        var width = (int)image.Frames[key].Width;
        var height = (int)image.Frames[key].Height;
        var pixels = image.Frames[key].GetByteArray(Openize.Heic.Decoder.PixelFormat.Bgra32);

        var wbitmap = new WriteableBitmap(width, height, 72, 72, PixelFormats.Bgra32, null);
        var rect = new Int32Rect(0, 0, width, height);
        wbitmap.WritePixels(rect, pixels, 4 * width, 0);

        using FileStream saveStream = new FileStream("output"+key+".png", FileMode.OpenOrCreate);
        PngBitmapEncoder encoder = new PngBitmapEncoder();
        encoder.Frames.Add(BitmapFrame.Create(wbitmap));
        encoder.Save(saveStream);
    }
}

Documentation

All public classes, methods and properties are documented in corresponding API_README:

HeicImage

Methods
Name Type Description Parameters Notes
Load HeicImage Reads the file meta data and creates a class object for further decoding of the file contents. Stream stream - File stream. This operation does not decode pixels. Use the default frame methods GetByteArray or GetInt32Array afterwards in order to decode pixels.
CanLoad bool Checks if the stream can be read as a heic image. Returns true if file header contains heic signarure, false otherwise Stream stream - File stream.
Properties
Name Type Description
Frames Dictionary<uint, HeicImageFrame> Dictionary of public Heic image frames with access by identifier.
AllFrames Dictionary<uint, HeicImageFrame> Dictionary of all Heic image frames with access by identifier.
DefaultImage HeicImageFrame Returns the default image frame, which is specified in meta data.

HeicImageFrame

Methods
Name Type Description Parameters
GetByteArray byte[] Get pixel data in the format of byte array. Each three or four bytes (the count depends on the pixel format) refer to one pixel left to right top to bottom line by line. PixelFormat pixelFormat - Pixel format that defines the order of colors and the presence of alpha byte. Rectangle boundsRectangle - Bounds of the requested area.
GetInt32Array int[] Get pixel data in the format of integer array. Each int value refers to one pixel left to right top to bottom line by line. PixelFormat pixelFormat - Pixel format that defines the order of colors. Rectangle boundsRectangle - Bounds of the requested area.
GetTextData string Get frame text data. Exists only for mime frame types.

Properties

Name Type Description
ImageType ImageFrameType Type of an image frame content.
Width uint Width of the image frame in pixels.
Height uint Height of the image frame in pixels.
HasAlpha bool Indicates the presence of transparency of transparency layer. True if frame is linked with alpha data frame, false otherwise.
IsHidden bool Indicates the fact that frame is marked as hidden. True if frame is hidden, false otherwise.
IsImage bool Indicates the fact that frame contains image data. True if frame is image, false otherwise.
IsDerived bool Indicates the fact that frame contains image transform data and is inherited from another frame(-s). True if frame is derived, false otherwise.
DerivativeType BoxType? Indicates the type of derivative content if the frame is derived.
AuxiliaryReferenceType AuxiliaryReferenceType Indicates the type of auxiliary reference layer if the frame type is auxiliary.
NumberOfChannels byte Number of channels with color data.
BitsPerChannel byte[] Bits per channel with color data.

License

Openize.HEIC is available under Openize License.

⚠️ Openize does not and cannot grant You a patent license for the utilization of HEVC/H.265 image compression/decompression technologies.

Openize.HEIC uses Openize.IsoBmff that is distributed under MIT License.

OSS Notice

Sample files used for tests and located in the "./Openize.Heic.Tests/TestsData/samples/nokia" folder belong to Nokia Technologies and are used according to Nokia High-Efficiency Image File Format (HEIF) License

Licensed Field means the non-commercial purposes of evaluation, testing and academic research in each non-commercial case to use, run, modify (in a way that still complies with the Specification) and copy the Software to (a) generate, using one or more encoded pictures as inputs, a file complying with the Specification and including the one or more encoded pictures that were given as inputs; and/or (b) read a file complying with the Specification, resulting into one or more encoded pictures included in the file as outputs.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  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 is compatible.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • net6.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Openize.Heic:

Package Downloads
Aspose.Imaging.HEIC.Adapter

Aspose.Imaging.HEIC.Adapter Combines 2 products Aspose.Imaging and Openize.HEIC, this allows to use the functions of both libraries as a single whole and expand export between formats HEIC format can be exported to all formats supported by Imaging, for example Png, Tiff, Pdf, Svg, Jpeg, Gif, Bmp, Emf, Wmf, J2k, Webp etc.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
24.6.0 81 6/10/2024
24.5.1 118 5/31/2024