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

Resize API #12

Open SkyeHoefling opened 3 years ago

SkyeHoefling commented 3 years ago

Description

Add ability to resize the primary image or thumbnail using the libheif native resize api.

New APIs

IImage

void Resize(int width, int height); // New API
void Resize(int widthAndHeight); // New API

Usage

The code below would generate a 200x200 square thumbnail. This use case is valuable for heic images that don't have an embedded thumbnail.

using (var image = new HeifImage("MyImage.heic"))
using (var primary = image.PrimaryImage())
{
  primary.Resize(200, 200);
  primary.Save("Output.jpeg", 90);
}
SkyeHoefling commented 3 years ago

The resize api is only available after decoding an image. Adding resize will not provide us with a performance improvement on thumbnail generation as the decode operation still needs to be invoked.

// Currently, heif_scaling_options is not defined yet. Pass a NULL pointer.
LIBHEIF_API
struct heif_error heif_image_scale_image(const struct heif_image* input,
                                         struct heif_image** output,
                                         int width, int height,
                                         const struct heif_scaling_options* options);