Khởi tạo dự án 3dtours
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
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
|
||||
};
|
||||
Reference in New Issue
Block a user