mirror of
https://github.com/C4illin/ConvertX.git
synced 2026-10-27 23:30:55 +01:00
fix(imagemagick): handle multi-page PDF outputs and improve rasterization quality (#593)
This commit is contained in:
@@ -461,6 +461,11 @@ export function convert(
|
||||
}
|
||||
}
|
||||
|
||||
// Increase rasterization quality for PDF input
|
||||
if (fileType === "pdf") {
|
||||
inputArgs.push("-density", "300");
|
||||
}
|
||||
|
||||
// Handle EMF files specifically to avoid LibreOffice delegate issues
|
||||
if (fileType === "emf") {
|
||||
// Use direct conversion without delegates for EMF files
|
||||
|
||||
+27
-1
@@ -1,5 +1,7 @@
|
||||
import { Cookie } from "elysia";
|
||||
import db from "../db/db";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { MAX_CONVERT_PROCESS } from "../helpers/env";
|
||||
import { normalizeFiletype, normalizeOutputFiletype } from "../helpers/normalizeFiletype";
|
||||
import { convert as convertassimp, properties as propertiesassimp } from "./assimp";
|
||||
@@ -187,7 +189,31 @@ export async function handleConvert(
|
||||
mainConverter(filePath, fileType, convertTo, targetPath, {}, converterName)
|
||||
.then((r) => {
|
||||
if (jobId.value) {
|
||||
query.run(jobId.value, fileName, newFileName, r);
|
||||
const dir = path.dirname(targetPath);
|
||||
const parsed = path.parse(targetPath);
|
||||
|
||||
const outputFiles = fs
|
||||
.readdirSync(dir)
|
||||
.filter((f) => {
|
||||
if (f === parsed.base) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return (
|
||||
f.startsWith(`${parsed.name}-`) &&
|
||||
f.endsWith(parsed.ext) &&
|
||||
/^\d+$/.test(f.slice(parsed.name.length + 1, -parsed.ext.length))
|
||||
);
|
||||
})
|
||||
.sort((a, b) => a.localeCompare(b, undefined, { numeric: true }));
|
||||
|
||||
if (outputFiles.length > 0) {
|
||||
for (const outputFile of outputFiles) {
|
||||
query.run(jobId.value, fileName, outputFile, r);
|
||||
}
|
||||
} else {
|
||||
query.run(jobId.value, fileName, newFileName, r);
|
||||
}
|
||||
}
|
||||
resolve(r);
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user