FileFormat.HEIC
24.7.1
See the version list below for details.
dotnet add package FileFormat.HEIC --version 24.7.1
NuGet\Install-Package FileFormat.HEIC -Version 24.7.1
<PackageReference Include="FileFormat.HEIC" Version="24.7.1" />
paket add FileFormat.HEIC --version 24.7.1
#r "nuget: FileFormat.HEIC, 24.7.1"
// Install FileFormat.HEIC as a Cake Addin #addin nuget:?package=FileFormat.HEIC&version=24.7.1 // Install FileFormat.HEIC as a Cake Tool #tool nuget:?package=FileFormat.HEIC&version=24.7.1
FileFormat.HEIC
FileFormat.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
FileFormat.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.
FileFormat.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.7.1:
- HeicImage changes:
- property "DefaultImage" renamed to "DefaultFrame";
- added method "GetByteArray()" that calls the same method from DefaultFrame;
- added method "GetInt32Array()" that calls the same method from DefaultFrame.
- HeicHeader changes:
- property "DefaultImageId" renamed to "DefaultFrameId".
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 .jpg using System.Windows.Media.Imaging.WriteableBitmap
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 file to .png using System.Windows.Media.Imaging.WriteableBitmap
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 .png using System.Drawing.Common.Bitmap
using (var fs = new FileStream("filename.heic", FileMode.Open))
{
HeicImage image = HeicImage.Load(fs);
var pixels = image.GetInt32Array(Heic.Decoder.PixelFormat.Argb32);
var width = (int)image.Width;
var height = (int)image.Height;
var i = 0;
Bitmap myBitmap = new Bitmap(width, height);
for (int y = 0; y < height; y++)
for (int x = 0; x < width; x++)
myBitmap.SetPixel(x, y, Color.FromArgb(pixels[i++]));
myBitmap.Save("output.png");
}
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(FileFormat.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:
- /FileFormat.Heic.Decoder/docs/API_README.md for FileFormat.Heic.Decoder;
- /FileFormat.IsoBmff/docs/API_README.md for FileFormat.IsoBmff.
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. |
|
GetByteArray | byte[] | Get pixel data of the default image frame 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. Returns null if frame does not contain image data. | 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 of the default image frame in the format of integer array. Each int value refers to one pixel left to right top to bottom line by line. Returns null if frame does not contain image data. | PixelFormat pixelFormat - Pixel format that defines the order of colors. Rectangle boundsRectangle - Bounds of the requested area. |
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. |
DefaultFrame | 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. Returns null if frame does not contain image data. | 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. Returns null if frame does not contain image data. | 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
FileFormat.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.
FileFormat.HEIC uses FileFormat.IsoBmff that is distributed under MIT License.
OSS Notice
Sample files used for tests and located in the "./FileFormat.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 | Versions 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. |
-
.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 FileFormat.HEIC:
Package | Downloads |
---|---|
Aspose.Imaging.HEIC.Adapter
Aspose.Imaging.HEIC.Adapter Combines 2 products Aspose.Imaging and FileFormat.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.