-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add inkscape for vector images
- Loading branch information
1 parent
b485bc9
commit f3740e9
Showing
5 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"); | ||
}); | ||
}); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters