Chevron DownCommand-Line Reference
Chevron DownAPI Reference


From-v3.1 Node.js-only

The experimental KTX2BasisUniversalTextureWriter class can encode a decoded image into a KTX2 texture.

File Extension.ktx2
File TypeBinary
Data Format
File FormatKTX2
Encoder TypeAsynchronous
Worker ThreadNo (but may run on separate native thread in browsers)


import ''; // only if using under Node
import {load, encode} from '';
import {KTX2BasisUniversalTextureWriter} from '';

const shannonPNG = 'shannon.png';

const image = await load(shannonPNG, ImageLoader, {image: {type: 'data'}});
const encodedData = await encode(image, KTX2BasisUniversalTextureWriter);

Data Format


useSRGBBooleanfalseIf true, the input is assumed to be in sRGB space.
qualityLevelNumber10Sets the ETC1S encoder's quality level, which controls the file size vs. quality tradeoff. Range is [1,255]
encodeUASTCBooleanfalseIf true, the encoder will output a UASTC texture, otherwise a ETC1S texture.
mipmapsBooleanfalseIf true mipmaps will be generated from the source images

WASM module

The writer applies BinomialLCC basis universal encoder. The libraries are loaded during runtime from URLs: