feat: add QOI codec, format encoders (BMP/ICO/JP2/QOI), fix JXL output bug

This commit is contained in:
SnapOtter
2026-05-08 00:09:55 +08:00
parent 5c9fa2de49
commit 390b5adb8c
7 changed files with 329 additions and 7 deletions
+10 -3
View File
@@ -4,6 +4,7 @@ import { readFile, rm, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { promisify } from "node:util";
import sharp from "sharp";
const execFileAsync = promisify(execFile);
@@ -440,8 +441,14 @@ async function decodeFits(buffer: Buffer): Promise<Buffer> {
}
}
// ── QOI decoder (stub -- real codec comes in Task 4) ──
// ── QOI decoder ──
async function decodeQoi(_buffer: Buffer): Promise<Buffer> {
throw new Error("QOI decode not yet implemented");
async function decodeQoi(buffer: Buffer): Promise<Buffer> {
const { qoiDecode } = await import("@snapotter/image-engine");
const { header, pixels } = qoiDecode(new Uint8Array(buffer));
return sharp(Buffer.from(pixels), {
raw: { width: header.width, height: header.height, channels: 4 },
})
.png()
.toBuffer();
}