encodeHeic

fun encodeHeic(bitmap: KiteBitmap, quality: Int = 50): ByteArray(source)

Encode bitmap as a HEIC file at quality, 0 to 100 (default 50), with the other settings of HeifEncodeOptions: 8-bit 4:2:0, tiles of 512 for a larger picture. See the overload with options.

Throws

if quality is outside 0..100, or the picture is too large for a HEIF reader

if the HEVC encoder of the imagekodec-heic module is not installed: add the module and call ImageKodecHeic.install()


fun encodeHeic(bitmap: KiteBitmap, options: HeifEncodeOptions, metadata: ImageMetadata = ImageMetadata(), cancellationCheck: () -> Unit? = null): ByteArray(source)

Encode bitmap as a HEIC file (#174): HEIF (ISO/IEC 23008-12) with HEVC pictures, coded by the intra encoder of the imagekodec-heic module, which ImageKodecHeic.install() registers.

Colour converts to Y, Cb and Cr with BT.601's matrix in full range and is signalled as sRGB (colr nclx 1, 13, 6, full range), as libheif and libavif write it; a lossless file uses the identity matrix in 4:4:4 and decodes to exactly bitmap. A gray bitmap codes luma alone, and a bitmap with any alpha below 255 adds an alpha auxiliary image, straight (not premultiplied). A picture wider or taller than HeifEncodeOptions.tileSize is a grid of tiles, which the runner of setTileRunner encodes. HeifEncodeOptions.thumbnailSize adds a thumbnail item, and HeifEncodeOptions.orientation writes irot and imir.

metadata adds its ICC profile as a colr prof property, its EXIF block as an Exif item and its XMP packet as a mime item, which readMetadata reads back; a gain map is not written. cancellationCheck runs at least once a tile and once a row of coding blocks, and what it throws comes out of this call as it is.

Throws

if the picture is too large for a HEIF reader (65535 on a side, or more than 256 tiles on a side of a grid), or for one coded picture when HeifEncodeOptions.tileSize is null

if the HEVC encoder of the imagekodec-heic module is not installed: add the module and call ImageKodecHeic.install()


fun encodeHeic(animation: KiteAnimation, options: HeifEncodeOptions, metadata: ImageMetadata = ImageMetadata(), cancellationCheck: () -> Unit? = null): ByteArray(source)

Encode animation as an animated HEIC file (#177): an HEVC image sequence written as encodeAvif writes an AV1 one, its pictures coded by the sequence encoder of the hvc1 encoder that a module registers with registerHeifEncoder (HeifEncoder.openSequence).

Throws

as encodeAvif with an animation does

if no hvc1 encoder is installed (add the imagekodec-heic module and call ImageKodecHeic.install()), or the one installed codes still pictures only