QOI utilities implemented in Typescript for the client.
Encode raw image data to QOI.
- data: A Uint8Array containing the pixel information (left to right, top to bottom)
- options
- width: Image width
- height: Image height
- channels: Number of color channels
- 3: RGB, 4: RGBA
- colorspace: Colorspace (purely informative)
- 0: sRGB (with linear alpha), 1: linear
- bytes: Raw binary of encoded image.
- blob: Blob representation of binary data.
Encode a white 2x2 image using sRGB (with linear alpha).
const imageData = new Uint8Array([255,255,255,255, 255,255,255,255, 255,255,255,255, 255,255,255,255]);
const encoder = new QOI.Encoder(imageData, {
width: 2,
height: 2,
channels: QOI.channels.RGBA,
colorspace: QOI.colorspace.sRGB
});
const url = URL.createObjectURL(encoder.blob);
open(url);
- RGB - 3
- RGBA - 4
- sRGB - 0
- linear - 1