FaceCompressor.compressWebpFromCroppedPortrait Method

Module: FaceCompressor

Definition

Compresses a pre-cropped portrait image to WebP so that its size does not exceed the given byte budget.

The WebP quality is searched automatically to find the highest quality whose encoded size fits within byte_budget. If even the lowest quality does not fit, the function fails and no data is returned.

Important

The input image must be in 24-bit BGR format. No compression model needs to be loaded since the standard WebP codec is used directly.

Uint8List compressWebpFromCroppedPortrait(Image image, int byteBudget)

Parameters

image Image
in Source pre-cropped portrait image to compress.

byteBudget int
in Maximum size in bytes of the compressed WebP buffer. Default recommended value is 800.

Returns

Uint8List
Buffer that receives the WebP-compressed image, whose size will not exceed byte_budget.

Exceptions

An error has occurred during Face Library execution.