Skip to content

Commit

Permalink
fix: pdf support in vips
Browse files Browse the repository at this point in the history
  • Loading branch information
C4illin committed Aug 23, 2024
1 parent 1535377 commit 8ca4f15
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM oven/bun:1.1.25-alpine as base
FROM oven/bun:1.1.25-alpine AS base
WORKDIR /app

# install dependencies into temp directory
Expand Down Expand Up @@ -40,6 +40,8 @@ RUN apk --no-cache add \
graphicsmagick \
ghostscript \
vips-tools \
vips-poppler \
vips-jxl \
libjxl-tools

# this might be needed for some latex use cases, will add it if needed.
Expand Down
31 changes: 19 additions & 12 deletions src/converters/vips.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,22 +113,29 @@ export function convert(
// .toFormat(convertTo)
// .toFile(targetPath);
// }
let action = "copy";
if (fileType === "pdf") {
action = "pdfload";
}

return new Promise((resolve, reject) => {
exec(`vips copy "${filePath}" "${targetPath}"`, (error, stdout, stderr) => {
if (error) {
reject(`error: ${error}`);
}
exec(
`vips ${action} "${filePath}" "${targetPath}"`,
(error, stdout, stderr) => {
if (error) {
reject(`error: ${error}`);
}

if (stdout) {
console.log(`stdout: ${stdout}`);
}
if (stdout) {
console.log(`stdout: ${stdout}`);
}

if (stderr) {
console.error(`stderr: ${stderr}`);
}
if (stderr) {
console.error(`stderr: ${stderr}`);
}

resolve("success");
});
resolve("success");
},
);
});
}

0 comments on commit 8ca4f15

Please sign in to comment.