mirror of
https://github.com/C4illin/ConvertX.git
synced 2025-10-28 10:33:30 +00:00
feat: add libjxl for jpegxl conversion
This commit is contained in:
51
Debian.Dockerfile
Normal file
51
Debian.Dockerfile
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
FROM oven/bun:1-debian as base
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# install dependencies into temp directory
|
||||||
|
# this will cache them and speed up future builds
|
||||||
|
FROM base AS install
|
||||||
|
RUN mkdir -p /temp/dev
|
||||||
|
COPY package.json bun.lockb /temp/dev/
|
||||||
|
RUN cd /temp/dev && bun install --frozen-lockfile
|
||||||
|
|
||||||
|
# install with --production (exclude devDependencies)
|
||||||
|
RUN mkdir -p /temp/prod
|
||||||
|
COPY package.json bun.lockb /temp/prod/
|
||||||
|
RUN cd /temp/prod && bun install --frozen-lockfile --production
|
||||||
|
|
||||||
|
# copy node_modules from temp directory
|
||||||
|
# then copy all (non-ignored) project files into the image
|
||||||
|
# FROM base AS prerelease
|
||||||
|
# COPY --from=install /temp/dev/node_modules node_modules
|
||||||
|
# COPY . .
|
||||||
|
|
||||||
|
# # [optional] tests & build
|
||||||
|
# ENV NODE_ENV=production
|
||||||
|
# RUN bun test
|
||||||
|
# RUN bun run build
|
||||||
|
|
||||||
|
# copy production dependencies and source code into final image
|
||||||
|
FROM base AS release
|
||||||
|
LABEL maintainer="Emrik Östling (C4illin)"
|
||||||
|
LABEL description="ConvertX: self-hosted online file converter supporting 700+ file formats."
|
||||||
|
LABEL repo="https://github.com/C4illin/ConvertX"
|
||||||
|
|
||||||
|
# install additional dependencies
|
||||||
|
RUN rm -rf /var/lib/apt/lists/partial && apt-get update -o Acquire::CompressionTypes::Order::=gz \
|
||||||
|
&& apt-get install -y \
|
||||||
|
pandoc \
|
||||||
|
texlive-latex-recommended \
|
||||||
|
texlive-fonts-recommended \
|
||||||
|
texlive-latex-extra \
|
||||||
|
ffmpeg \
|
||||||
|
graphicsmagick \
|
||||||
|
ghostscript \
|
||||||
|
libvips-tools
|
||||||
|
|
||||||
|
COPY --from=install /temp/prod/node_modules node_modules
|
||||||
|
# COPY --from=prerelease /app/src/index.tsx /app/src/
|
||||||
|
# COPY --from=prerelease /app/package.json .
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
EXPOSE 3000/tcp
|
||||||
|
ENTRYPOINT [ "bun", "run", "./src/index.tsx" ]
|
||||||
14
Dockerfile
14
Dockerfile
@@ -1,4 +1,4 @@
|
|||||||
FROM oven/bun:1-debian as base
|
FROM oven/bun:1-alpine as base
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# install dependencies into temp directory
|
# install dependencies into temp directory
|
||||||
@@ -31,16 +31,16 @@ LABEL description="ConvertX: self-hosted online file converter supporting 700+ f
|
|||||||
LABEL repo="https://github.com/C4illin/ConvertX"
|
LABEL repo="https://github.com/C4illin/ConvertX"
|
||||||
|
|
||||||
# install additional dependencies
|
# install additional dependencies
|
||||||
RUN rm -rf /var/lib/apt/lists/partial && apt-get update -o Acquire::CompressionTypes::Order::=gz \
|
RUN apk update && apk add --no-cache \
|
||||||
&& apt-get install -y \
|
|
||||||
pandoc \
|
pandoc \
|
||||||
texlive-latex-recommended \
|
texlive \
|
||||||
texlive-fonts-recommended \
|
texmf-dist-fontsextra \
|
||||||
texlive-latex-extra \
|
texmf-dist-latexextra \
|
||||||
ffmpeg \
|
ffmpeg \
|
||||||
graphicsmagick \
|
graphicsmagick \
|
||||||
ghostscript \
|
ghostscript \
|
||||||
libvips-tools
|
vips-tools \
|
||||||
|
libjxl-tools
|
||||||
|
|
||||||
COPY --from=install /temp/prod/node_modules node_modules
|
COPY --from=install /temp/prod/node_modules node_modules
|
||||||
# COPY --from=prerelease /app/src/index.tsx /app/src/
|
# COPY --from=prerelease /app/src/index.tsx /app/src/
|
||||||
|
|||||||
71
src/converters/libjxl.ts
Normal file
71
src/converters/libjxl.ts
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
import { exec } from "node:child_process";
|
||||||
|
|
||||||
|
// declare possible conversions
|
||||||
|
export const properties = {
|
||||||
|
from: {
|
||||||
|
jxl: ["jxl"],
|
||||||
|
images: [
|
||||||
|
"apng",
|
||||||
|
"exr",
|
||||||
|
"gif",
|
||||||
|
"jpeg",
|
||||||
|
"pam",
|
||||||
|
"pfm",
|
||||||
|
"pgm",
|
||||||
|
"pgx",
|
||||||
|
"png",
|
||||||
|
"ppm",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
to: {
|
||||||
|
jxl: [
|
||||||
|
"apng",
|
||||||
|
"exr",
|
||||||
|
"gif",
|
||||||
|
"jpeg",
|
||||||
|
"pam",
|
||||||
|
"pfm",
|
||||||
|
"pgm",
|
||||||
|
"pgx",
|
||||||
|
"png",
|
||||||
|
"ppm",
|
||||||
|
],
|
||||||
|
images: ["jxl"],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export function convert(
|
||||||
|
filePath: string,
|
||||||
|
fileType: string,
|
||||||
|
convertTo: string,
|
||||||
|
targetPath: string,
|
||||||
|
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
||||||
|
options?: any,
|
||||||
|
): Promise<string> {
|
||||||
|
let tool = "";
|
||||||
|
if (fileType === "jxl") {
|
||||||
|
tool = "djxl";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (convertTo === "jxl") {
|
||||||
|
tool = "cjxl";
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
exec(`${tool} "${filePath}" "${targetPath}"`, (error, stdout, stderr) => {
|
||||||
|
if (error) {
|
||||||
|
reject(`error: ${error}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stdout) {
|
||||||
|
console.log(`stdout: ${stdout}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stderr) {
|
||||||
|
console.error(`stderr: ${stderr}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
resolve("success");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -20,6 +20,11 @@ import {
|
|||||||
properties as propertiesPdflatex,
|
properties as propertiesPdflatex,
|
||||||
} from "./pdflatex";
|
} from "./pdflatex";
|
||||||
|
|
||||||
|
import {
|
||||||
|
convert as convertLibjxl,
|
||||||
|
properties as propertiesLibjxl,
|
||||||
|
} from "./libjxl";
|
||||||
|
|
||||||
import { normalizeFiletype } from "../helpers/normalizeFiletype";
|
import { normalizeFiletype } from "../helpers/normalizeFiletype";
|
||||||
|
|
||||||
// This should probably be reconstructed so that the functions are not imported instead the functions hook into this to make the converters more modular
|
// This should probably be reconstructed so that the functions are not imported instead the functions hook into this to make the converters more modular
|
||||||
@@ -50,6 +55,10 @@ const properties: {
|
|||||||
) => any;
|
) => any;
|
||||||
};
|
};
|
||||||
} = {
|
} = {
|
||||||
|
libjxl: {
|
||||||
|
properties: propertiesLibjxl,
|
||||||
|
converter: convertLibjxl,
|
||||||
|
},
|
||||||
vips: {
|
vips: {
|
||||||
properties: propertiesImage,
|
properties: propertiesImage,
|
||||||
converter: convertImage,
|
converter: convertImage,
|
||||||
|
|||||||
Reference in New Issue
Block a user