fix: JXL decode fallback and Playwright remote container support

Add djxl (libjxl-tools) as primary JXL decoder with ImageMagick
fallback — fixes JXL format failures on Ubuntu where stock ImageMagick
lacks a JXL delegate. Also make Playwright Docker config respect
BASE_URL env var for testing against remote containers.
This commit is contained in:
SnapOtter
2026-04-26 02:53:02 +08:00
parent c061ad13ce
commit 86db131198
3 changed files with 15 additions and 3 deletions
+11 -1
View File
@@ -216,13 +216,23 @@ async function decodeBmp(buffer: Buffer): Promise<Buffer> {
}
async function decodeJxl(buffer: Buffer): Promise<Buffer> {
const cmd = await findMagickCmd();
const id = randomUUID();
const inputPath = join(tmpdir(), `jxl-in-${id}.jxl`);
const outputPath = join(tmpdir(), `jxl-out-${id}.png`);
try {
await writeFile(inputPath, buffer);
// Try djxl first (from libjxl-tools) — works even when ImageMagick
// lacks a JXL delegate (common on Ubuntu stock packages).
try {
await execFileAsync("djxl", [inputPath, outputPath], { timeout: 120_000 });
return await readFile(outputPath);
} catch {
// djxl not available, fall back to ImageMagick
}
const cmd = await findMagickCmd();
await execFileAsync(cmd, magickArgs(cmd, [inputPath, `png:${outputPath}`]), {
timeout: 120_000,
});