Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion functions/engines/NodeCanvasFactory.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Canvas = require("canvas");
const Canvas = require("@napi-rs/canvas");
const assert = require("assert").strict;

class NodeCanvasFactory {
Expand Down
8 changes: 4 additions & 4 deletions functions/engines/native.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const NodeCanvasFactory = require("./NodeCanvasFactory");
const fs = require("fs-extra");
const path = require("path");
const Canvas = require("canvas");
const Canvas = require("@napi-rs/canvas");

let pdfjsLibPromise;
const getPdfjsLib = () => {
Expand Down Expand Up @@ -36,7 +36,7 @@ const pdfPageToPng = async (

await page.render(renderContext).promise;

const image = canvasAndContext.canvas.toBuffer();
const image = canvasAndContext.canvas.toBuffer("image/png");
const pngFileName = isSinglePage
? filename
: filename.replace(".png", `-${pageNumber - 1}.png`);
Expand Down Expand Up @@ -85,7 +85,7 @@ const applyMask = async (
coordinates.x1 - coordinates.x0,
coordinates.y1 - coordinates.y0,
);
fs.writeFileSync(pngFilePath, canvas.toBuffer());
fs.writeFileSync(pngFilePath, canvas.toBuffer("image/png"));
};

const applyCrop = async (
Expand All @@ -110,7 +110,7 @@ const applyCrop = async (
);
fs.writeFileSync(
pngFilePath.replace(".png", `-${index}.png`),
canvas.toBuffer(),
canvas.toBuffer("image/png"),
);
};

Expand Down
Loading