Files
3dtours/backend/utils/imageHelper.js
T
2026-06-07 16:55:00 +07:00

24 lines
699 B
JavaScript

const sharp = require('sharp');
/**
* Resizes an image to standard 8K resolution (8192x4096) with 2:1 ratio and saves as JPEG
* @param {string} inputPath - Path to the original uploaded file
* @param {string} outputPath - Path to save the processed 8K JPEG image
*/
const resizeTo8K = async (inputPath, outputPath) => {
try {
await sharp(inputPath)
.resize(8192, 4096, {
fit: 'fill' // Ensures the output is exactly 8192x4096
})
.jpeg({ quality: 90 })
.toFile(outputPath);
} catch (error) {
throw new Error(`Sharp image processing failed: ${error.message}`);
}
};
module.exports = {
resizeTo8K
};