pdf2html
Version:
PDF to HTML or Text conversion using Apache Tika. Also generate PDF thumbnail using Apache PDFBox.
22 lines (19 loc) • 588 B
JavaScript
// lib/ImageProcessor.js
const sharp = require('sharp');
/**
* Image processing utilities
*/
class ImageProcessor {
static async resize(sourceFilepath, targetFilepath, options) {
try {
await sharp(sourceFilepath)
.resize(options.width, options.height, {
fit: 'fill', // equivalent to gm's '!' option for exact dimensions
})
.toFile(targetFilepath);
} catch (err) {
throw new Error(`Image resize failed: ${err.message}`);
}
}
}
module.exports = ImageProcessor;