UNPKG

pdf2html

Version:

PDF to HTML or Text conversion using Apache Tika. Also generate PDF thumbnail using Apache PDFBox.

24 lines (21 loc) 675 B
// lib/ImageProcessor.js const gm = require('gm').subClass({ imageMagick: true }); /** * Image processing utilities */ class ImageProcessor { static async resize(sourceFilepath, targetFilepath, options) { return new Promise((resolve, reject) => { gm(sourceFilepath) .resize(options.width, options.height, '!') .write(targetFilepath, (err) => { if (err) { reject(new Error(`Image resize failed: ${err.message}`)); return; } resolve(); }); }); } } module.exports = ImageProcessor;