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,
});
+1
View File
@@ -148,6 +148,7 @@ RUN for i in 1 2 3; do apt-get -o Acquire::Retries=3 update && break || sleep $(
apt-get install -y --no-install-recommends \
tini \
imagemagick \
libjxl-tools \
libraw-dev \
libopenexr-dev \
potrace \
+3 -2
View File
@@ -6,7 +6,8 @@ const authFile = path.join(__dirname, "test-results", ".auth", "user.json");
// Point raw-fetch tests (api.spec, security.spec, people.spec, rbac.spec) at
// the Docker container instead of the dev-server default (port 13490).
// Start the container with: SKIP_MUST_CHANGE_PASSWORD=true docker compose -f docker/docker-compose.yml up -d
process.env.API_URL ??= "http://localhost:1349";
const containerUrl = process.env.BASE_URL || "http://localhost:1349";
process.env.API_URL ??= containerUrl;
export default defineConfig({
testDir: "./tests/e2e",
@@ -19,7 +20,7 @@ export default defineConfig({
workers: 1,
reporter: [["html", { open: "never" }], ["list"]],
use: {
baseURL: "http://localhost:1349",
baseURL: containerUrl,
screenshot: "only-on-failure",
trace: "retain-on-failure",
},