diff --git a/Dockerfile b/Dockerfile index 8e007d4..664364c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -50,7 +50,8 @@ RUN apk --no-cache add \ vips-poppler \ vips-jxl \ libjxl-tools \ - assimp + assimp \ + inkscape # this might be needed for some latex use cases, will add it if needed. # texmf-dist-fontsextra \ diff --git a/README.md b/README.md index 1f6ebe6..f6bed71 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ A self-hosted online file converter. Supports over a thousand different formats. | [XeLaTeX](https://tug.org/xetex/) | LaTeX | 1 | 1 | | [Pandoc](https://pandoc.org/) | Documents | 43 | 65 | | [GraphicsMagick](http://www.graphicsmagick.org/) | Images | 166 | 133 | +| [Inkscape](https://inkscape.org/) | Vector images | 7 | 17 | | [FFmpeg](https://ffmpeg.org/) | Video | ~473 | ~280 | diff --git a/src/converters/inkscape.ts b/src/converters/inkscape.ts new file mode 100644 index 0000000..1534d17 --- /dev/null +++ b/src/converters/inkscape.ts @@ -0,0 +1,64 @@ +import { exec } from "node:child_process"; + +export const properties = { + from: { + images: [ + "svg", + "pdf", + "eps", + "ps", + "wmf", + "emf", + "png" + ] + }, + to: { + images: [ + "dxf", + "emf", + "eps", + "fxg", + "gpl", + "hpgl", + "html", + "odg", + "pdf", + "png", + "pov", + "ps", + "sif", + "svg", + "svgz", + "tex", + "wmf", + ] + }, + }; + + export function convert( + filePath: string, + fileType: string, + convertTo: string, + targetPath: string, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + options?: unknown, + ): Promise { + return new Promise((resolve, reject) => { + exec(`inkscape "${filePath}" -o "${targetPath}"`, (error, stdout, stderr) => { + if (error) { + reject(`error: ${error}`); + } + + if (stdout) { + console.log(`stdout: ${stdout}`); + } + + if (stderr) { + console.error(`stderr: ${stderr}`); + } + + resolve("Done"); + }); + }); + } + \ No newline at end of file diff --git a/src/converters/main.ts b/src/converters/main.ts index 39ba442..7169cf0 100644 --- a/src/converters/main.ts +++ b/src/converters/main.ts @@ -2,6 +2,7 @@ import { normalizeFiletype } from "../helpers/normalizeFiletype"; import { convert as convertassimp, properties as propertiesassimp } from "./assimp"; import { convert as convertFFmpeg, properties as propertiesFFmpeg } from "./ffmpeg"; import { convert as convertGraphicsmagick, properties as propertiesGraphicsmagick } from "./graphicsmagick"; +import { convert as convertInkscape, properties as propertiesInkscape } from "./inkscape"; import { convert as convertLibjxl, properties as propertiesLibjxl } from "./libjxl"; import { convert as convertPandoc, properties as propertiesPandoc } from "./pandoc"; import { convert as convertresvg, properties as propertiesresvg } from "./resvg"; @@ -63,6 +64,10 @@ const properties: Record< properties: propertiesGraphicsmagick, converter: convertGraphicsmagick, }, + inkscape: { + properties: propertiesInkscape, + converter: convertInkscape, + }, assimp: { properties: propertiesassimp, converter: convertassimp, diff --git a/src/helpers/printVersions.ts b/src/helpers/printVersions.ts index 8eb5064..5372f4a 100644 --- a/src/helpers/printVersions.ts +++ b/src/helpers/printVersions.ts @@ -53,6 +53,16 @@ if (process.env.NODE_ENV === "production") { } }); + exec("inkscape --version", (error, stdout) => { + if (error) { + console.error("Inkscape is not installed."); + } + + if (stdout) { + console.log(stdout.split("\n")[0]); + } + }); + exec("djxl --version", (error, stdout) => { if (error) { console.error("libjxl-tools is not installed.");