Files
ConvertX/src/converters/djvu.ts
T
al-n aabd0ccb3d feat: add DjVu conversion support (#612)
* feat: add DjVu conversion support

* fix: support DjVu aliases and prioritize converter

* fix: restore DjVu converter priority

* [autofix.ci] apply automated fixes

---------

Co-authored-by: Alex N <alex@alex-n.net>
Co-authored-by: Emrik Östling <emrik.ostling@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-10-14 21:53:06 +02:00

40 lines
871 B
TypeScript

import { execFile as execFileOriginal } from "node:child_process";
import type { ExecFileFn } from "./types";
export const properties = {
from: {
document: ["djvu", "djv"],
},
to: {
document: ["pdf", "tiff"],
},
};
export function convert(
filePath: string,
_fileType: string,
convertTo: string,
targetPath: string,
_options?: unknown,
execFile: ExecFileFn = execFileOriginal,
): Promise<string> {
return new Promise((resolve, reject) => {
execFile("ddjvu", [`-format=${convertTo}`, filePath, targetPath], (error, stdout, stderr) => {
if (error) {
reject(`error: ${error}${stderr ? `\nstderr: ${stderr}` : ""}`);
return;
}
if (stdout) {
console.log(`stdout: ${stdout}`);
}
if (stderr) {
console.error(`stderr: ${stderr}`);
}
resolve("Done");
});
});
}