mirror of
https://github.com/C4illin/ConvertX.git
synced 2025-10-24 08:33:56 +00:00
Merge pull request #186 from C10udburst/main
feat: add inkscape for vector images
This commit is contained in:
@@ -50,7 +50,8 @@ RUN apk --no-cache add \
|
|||||||
vips-poppler \
|
vips-poppler \
|
||||||
vips-jxl \
|
vips-jxl \
|
||||||
libjxl-tools \
|
libjxl-tools \
|
||||||
assimp
|
assimp \
|
||||||
|
inkscape
|
||||||
|
|
||||||
# this might be needed for some latex use cases, will add it if needed.
|
# this might be needed for some latex use cases, will add it if needed.
|
||||||
# texmf-dist-fontsextra \
|
# texmf-dist-fontsextra \
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ A self-hosted online file converter. Supports over a thousand different formats.
|
|||||||
| [XeLaTeX](https://tug.org/xetex/) | LaTeX | 1 | 1 |
|
| [XeLaTeX](https://tug.org/xetex/) | LaTeX | 1 | 1 |
|
||||||
| [Pandoc](https://pandoc.org/) | Documents | 43 | 65 |
|
| [Pandoc](https://pandoc.org/) | Documents | 43 | 65 |
|
||||||
| [GraphicsMagick](http://www.graphicsmagick.org/) | Images | 166 | 133 |
|
| [GraphicsMagick](http://www.graphicsmagick.org/) | Images | 166 | 133 |
|
||||||
|
| [Inkscape](https://inkscape.org/) | Vector images | 7 | 17 |
|
||||||
| [FFmpeg](https://ffmpeg.org/) | Video | ~473 | ~280 |
|
| [FFmpeg](https://ffmpeg.org/) | Video | ~473 | ~280 |
|
||||||
|
|
||||||
<!-- many ffmpeg fileformats are duplicates -->
|
<!-- many ffmpeg fileformats are duplicates -->
|
||||||
|
|||||||
64
src/converters/inkscape.ts
Normal file
64
src/converters/inkscape.ts
Normal file
@@ -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<string> {
|
||||||
|
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");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@@ -2,6 +2,7 @@ import { normalizeFiletype } from "../helpers/normalizeFiletype";
|
|||||||
import { convert as convertassimp, properties as propertiesassimp } from "./assimp";
|
import { convert as convertassimp, properties as propertiesassimp } from "./assimp";
|
||||||
import { convert as convertFFmpeg, properties as propertiesFFmpeg } from "./ffmpeg";
|
import { convert as convertFFmpeg, properties as propertiesFFmpeg } from "./ffmpeg";
|
||||||
import { convert as convertGraphicsmagick, properties as propertiesGraphicsmagick } from "./graphicsmagick";
|
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 convertLibjxl, properties as propertiesLibjxl } from "./libjxl";
|
||||||
import { convert as convertPandoc, properties as propertiesPandoc } from "./pandoc";
|
import { convert as convertPandoc, properties as propertiesPandoc } from "./pandoc";
|
||||||
import { convert as convertresvg, properties as propertiesresvg } from "./resvg";
|
import { convert as convertresvg, properties as propertiesresvg } from "./resvg";
|
||||||
@@ -63,6 +64,10 @@ const properties: Record<
|
|||||||
properties: propertiesGraphicsmagick,
|
properties: propertiesGraphicsmagick,
|
||||||
converter: convertGraphicsmagick,
|
converter: convertGraphicsmagick,
|
||||||
},
|
},
|
||||||
|
inkscape: {
|
||||||
|
properties: propertiesInkscape,
|
||||||
|
converter: convertInkscape,
|
||||||
|
},
|
||||||
assimp: {
|
assimp: {
|
||||||
properties: propertiesassimp,
|
properties: propertiesassimp,
|
||||||
converter: convertassimp,
|
converter: convertassimp,
|
||||||
|
|||||||
@@ -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) => {
|
exec("djxl --version", (error, stdout) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error("libjxl-tools is not installed.");
|
console.error("libjxl-tools is not installed.");
|
||||||
|
|||||||
Reference in New Issue
Block a user