From fcb922d52b55e228a8dbf28cbfb54ca7be49d9fc Mon Sep 17 00:00:00 2001 From: Rishi Ghan Date: Tue, 27 Jul 2021 22:01:26 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=89=20ebook-meta=20for=20--get-cover?= =?UTF-8?q?=20works=20like=20a=20dream?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/uncompression.utils.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/utils/uncompression.utils.ts b/utils/uncompression.utils.ts index 91fa443..02156d1 100644 --- a/utils/uncompression.utils.ts +++ b/utils/uncompression.utils.ts @@ -70,7 +70,6 @@ export const extractCoverFromFile = async ( return new Promise(async (resolve, reject) => { try { const constructedPaths = constructPaths(extractionOptions, walkedFolder); - console.log(constructedPaths); const calibre = new Calibre({ library: path.resolve("./userdata/calibre-lib"), }); @@ -86,19 +85,25 @@ export const extractCoverFromFile = async ( logger.error(`${error}: Couldn't create directory.`); } let result: string; + const targetCoverImageFilePath = path.resolve(constructedPaths.targetPath + "/" + walkedFolder.name + "_cover.jpg") result = await calibre.run( "ebook-meta", [path.resolve(constructedPaths.inputFilePath)], { - getCover: path.resolve(constructedPaths.targetPath + "/cover.jpg"), + getCover: targetCoverImageFilePath, } ); - console.log("AJSDASDLASDASDASLK!@#!@#!@#!#@#!@#!@", result); + // create renditions + const renditionPath = constructedPaths.targetPath + "/" + walkedFolder.name + "_200px.jpg"; + await resizeImage(targetCoverImageFilePath, path.resolve(renditionPath), 200); + resolve({ - name: "cover.jpg", - path: constructedPaths.targetPath, + name: walkedFolder.name, + path: constructedPaths.targetPath + "/" + walkedFolder.name + "_200px.jpg", //renditionPath fileSize: 0, containedIn: walkedFolder.containedIn, + //originalPath: + //extension: }); } catch (error) { console.log(error);