mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
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:
@@ -216,13 +216,23 @@ async function decodeBmp(buffer: Buffer): Promise<Buffer> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function decodeJxl(buffer: Buffer): Promise<Buffer> {
|
async function decodeJxl(buffer: Buffer): Promise<Buffer> {
|
||||||
const cmd = await findMagickCmd();
|
|
||||||
const id = randomUUID();
|
const id = randomUUID();
|
||||||
const inputPath = join(tmpdir(), `jxl-in-${id}.jxl`);
|
const inputPath = join(tmpdir(), `jxl-in-${id}.jxl`);
|
||||||
const outputPath = join(tmpdir(), `jxl-out-${id}.png`);
|
const outputPath = join(tmpdir(), `jxl-out-${id}.png`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await writeFile(inputPath, buffer);
|
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}`]), {
|
await execFileAsync(cmd, magickArgs(cmd, [inputPath, `png:${outputPath}`]), {
|
||||||
timeout: 120_000,
|
timeout: 120_000,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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 \
|
apt-get install -y --no-install-recommends \
|
||||||
tini \
|
tini \
|
||||||
imagemagick \
|
imagemagick \
|
||||||
|
libjxl-tools \
|
||||||
libraw-dev \
|
libraw-dev \
|
||||||
libopenexr-dev \
|
libopenexr-dev \
|
||||||
potrace \
|
potrace \
|
||||||
|
|||||||
@@ -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
|
// Point raw-fetch tests (api.spec, security.spec, people.spec, rbac.spec) at
|
||||||
// the Docker container instead of the dev-server default (port 13490).
|
// 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
|
// 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({
|
export default defineConfig({
|
||||||
testDir: "./tests/e2e",
|
testDir: "./tests/e2e",
|
||||||
@@ -19,7 +20,7 @@ export default defineConfig({
|
|||||||
workers: 1,
|
workers: 1,
|
||||||
reporter: [["html", { open: "never" }], ["list"]],
|
reporter: [["html", { open: "never" }], ["list"]],
|
||||||
use: {
|
use: {
|
||||||
baseURL: "http://localhost:1349",
|
baseURL: containerUrl,
|
||||||
screenshot: "only-on-failure",
|
screenshot: "only-on-failure",
|
||||||
trace: "retain-on-failure",
|
trace: "retain-on-failure",
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user