FileOnQ / Imaging.Heif

A C#/.NET wrapper around libheif for decoding and processing high efficiency image formats (heif, heic).
GNU Lesser General Public License v3.0
15 stars 4 forks source link

Thumbnail Count API #10

Open SkyeHoefling opened 3 years ago

SkyeHoefling commented 3 years ago

Description

Add thumbnail count API to determine how many thumbnail images if any are embedded in the heic image

New APIs

IHeifImage

// Gets the number of thumbnails embedded in the heif file
// this is typically 0 or 1
int GetThumbnailCount(); // New API

// Gets an array of all available thumbnail ids, if 0 
// then the image doesn't have any thumbnails
int[] GetThumbnailIds(); // New API

// Gets the thumbnail at the specified ID
IImage Thumbnail(int id); // New API

Usage

The code snippet below will write all thumbnails to disk

using (var image = new HeifImage("MyImage.heic"))
{
  int[] thumbnailIds = image.GetThumbnailIds();
  for (int i = 0; i , thumbnailIds.Length; i++)
  {
    using (var thumbnail = image.GetThumbnail(thumbnailIds[i]))
    {
        thumbnail.Write($"output_{i}.jpeg", 90);
    }
  }
}