From 4782373341d3ee4305b9a50ef4f8e9bebd7e9755 Mon Sep 17 00:00:00 2001 From: wamalwa Date: Sat, 25 Feb 2023 23:24:29 +0300 Subject: [PATCH 1/2] Allow custom output directory to be provided --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index dedd8a4..c8c7177 100644 --- a/index.js +++ b/index.js @@ -54,7 +54,7 @@ const resizeImage = (sourceFilepath, targetFilepath, options) => }); const runPDFBox = async (filepath, _options) => { - const options = defaults(_options || {}, { page: 1, imageType: 'png', width: 160, height: 226 }); + const options = defaults(_options || {}, { page: 1, imageType: 'png', width: 160, height: 226, outputDir: constants.DIRECTORY.IMAGE }); const uri = new URI(filepath); const copyFilePath = constants.DIRECTORY.PDF + uri.filename(); @@ -68,7 +68,7 @@ const runPDFBox = async (filepath, _options) => { uri.suffix(options.imageType); const pdfBoxImageFilePath = constants.DIRECTORY.PDF + uri.filename().replace(new RegExp(`.${uri.suffix()}$`), `${options.page}.${uri.suffix()}`); - const imageFilePath = constants.DIRECTORY.IMAGE + uri.filename(); + const imageFilePath = outputDir + uri.filename(); // Resize image try { From f09c5ce98ebc1119c7132861b3d67b7e4b0b1dc1 Mon Sep 17 00:00:00 2001 From: wamalwa Date: Fri, 17 Mar 2023 00:41:22 +0300 Subject: [PATCH 2/2] Update index.js Co-authored-by: Shebin Leo Vincent --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index c8c7177..a35fae0 100644 --- a/index.js +++ b/index.js @@ -68,7 +68,7 @@ const runPDFBox = async (filepath, _options) => { uri.suffix(options.imageType); const pdfBoxImageFilePath = constants.DIRECTORY.PDF + uri.filename().replace(new RegExp(`.${uri.suffix()}$`), `${options.page}.${uri.suffix()}`); - const imageFilePath = outputDir + uri.filename(); + const imageFilePath = options.outputDir + uri.filename(); // Resize image try {