mirror of
https://github.com/C4illin/ConvertX.git
synced 2025-11-01 20:43:38 +00:00
feat: add dvisvgm
This commit is contained in:
@@ -40,15 +40,17 @@ RUN apt-get update && apt-get install -y \
|
||||
assimp-utils \
|
||||
calibre \
|
||||
dcraw \
|
||||
dvisvgm \
|
||||
ffmpeg \
|
||||
ghostscript \
|
||||
graphicsmagick \
|
||||
imagemagick-7.q16 \
|
||||
inkscape \
|
||||
libheif-examples \
|
||||
libjxl-tools \
|
||||
libva2 \
|
||||
libvips-tools \
|
||||
imagemagick-7.q16 \
|
||||
mupdf-tools \
|
||||
pandoc \
|
||||
poppler-utils \
|
||||
potrace \
|
||||
|
||||
@@ -33,6 +33,7 @@ A self-hosted online file converter. Supports over a thousand different formats.
|
||||
| [XeLaTeX](https://tug.org/xetex/) | LaTeX | 1 | 1 |
|
||||
| [Calibre](https://calibre-ebook.com/) | E-books | 26 | 19 |
|
||||
| [Pandoc](https://pandoc.org/) | Documents | 43 | 65 |
|
||||
| [dvisvgm](https://dvisvgm.de/) | Vector images | 4 | 2 |
|
||||
| [ImageMagick](https://imagemagick.org/) | Images | 245 | 183 |
|
||||
| [GraphicsMagick](http://www.graphicsmagick.org/) | Images | 167 | 130 |
|
||||
| [Inkscape](https://inkscape.org/) | Vector images | 7 | 17 |
|
||||
@@ -88,7 +89,7 @@ All are optional, JWT_SECRET is recommended to be set.
|
||||
| AUTO_DELETE_EVERY_N_HOURS | 24 | Checks every n hours for files older then n hours and deletes them, set to 0 to disable |
|
||||
| WEBROOT | | The address to the root path setting this to "/convert" will serve the website on "example.com/convert/" |
|
||||
| FFMPEG_ARGS | | Arguments to pass to ffmpeg, e.g. `-preset veryfast` |
|
||||
| HIDE_HISTORY | false | Hide the history page |
|
||||
| HIDE_HISTORY | false | Hide the history page |
|
||||
|
||||
### Docker images
|
||||
|
||||
@@ -133,17 +134,12 @@ Use [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/#summar
|
||||
|
||||
## Todo
|
||||
|
||||
- [x] Add messages for errors in converters
|
||||
- [x] Add searchable list of formats
|
||||
- [ ] Add options for converters
|
||||
- [ ] Divide index.tsx into smaller components
|
||||
- [ ] Add tests
|
||||
- [ ] Make the upload button nicer and more easy to drop files on. Support copy paste as well if possible.
|
||||
- [ ] Make errors logs visible from the web ui
|
||||
- [ ] Add more converters:
|
||||
- [ ] [deark](https://github.com/jsummers/deark)
|
||||
- [ ] LibreOffice
|
||||
- [ ] [dvisvgm](https://github.com/mgieseki/dvisvgm)
|
||||
|
||||
## Contributors
|
||||
|
||||
|
||||
@@ -14,5 +14,6 @@ services:
|
||||
# - FFMPEG_ARGS=-hwaccel vulkan # additional arguments to pass to ffmpeg
|
||||
# - WEBROOT=/convertx # the root path of the web interface, leave empty to disable
|
||||
# - HIDE_HISTORY=true # hides the history tab in the web interface, defaults to false
|
||||
- TZ=Europe/Stockholm # set your timezone, defaults to UTC
|
||||
ports:
|
||||
- 3000:3000
|
||||
|
||||
52
src/converters/dvisvgm.ts
Normal file
52
src/converters/dvisvgm.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { execFile } from "node:child_process";
|
||||
|
||||
export const properties = {
|
||||
from: {
|
||||
images: ["dvi", "xdv", "pdf", "eps"],
|
||||
},
|
||||
to: {
|
||||
images: ["svg", "svgz"],
|
||||
},
|
||||
};
|
||||
|
||||
export function convert(
|
||||
filePath: string,
|
||||
fileType: string,
|
||||
convertTo: string,
|
||||
targetPath: string,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
options?: unknown,
|
||||
): Promise<string> {
|
||||
const inputArgs: string[] = [];
|
||||
if (fileType === "eps") {
|
||||
inputArgs.push("--eps");
|
||||
}
|
||||
if (fileType === "pdf") {
|
||||
inputArgs.push("--pdf");
|
||||
}
|
||||
if (convertTo === "svgz") {
|
||||
inputArgs.push("-z");
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
execFile(
|
||||
"dvisvgm",
|
||||
[...inputArgs, 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");
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import { convert as convertCalibre, properties as propertiesCalibre } from "./ca
|
||||
import { convert as convertLibheif, properties as propertiesLibheif } from "./libheif";
|
||||
import { convert as convertPotrace, properties as propertiesPotrace } from "./potrace";
|
||||
import { convert as convertImagemagick, properties as propertiesImagemagick } from "./imagemagick";
|
||||
import { convert as convertDvisvgm, properties as propertiesDvisvgm } from "./dvisvgm";
|
||||
|
||||
|
||||
// This should probably be reconstructed so that the functions are not imported instead the functions hook into this to make the converters more modular
|
||||
@@ -72,6 +73,10 @@ const properties: Record<
|
||||
properties: propertiesPandoc,
|
||||
converter: convertPandoc,
|
||||
},
|
||||
dvisvgm: {
|
||||
properties: propertiesDvisvgm,
|
||||
converter: convertDvisvgm,
|
||||
},
|
||||
imagemagick: {
|
||||
properties: propertiesImagemagick,
|
||||
converter: convertImagemagick,
|
||||
|
||||
Reference in New Issue
Block a user