28 lines
902 B
JavaScript
28 lines
902 B
JavaScript
const sharp = require('sharp');
|
|
const path = require('path');
|
|
const fs = require('fs');
|
|
|
|
async function checkImageInfo() {
|
|
const imageDir = path.join(__dirname, '产品', '飞牛 NAS', 'fyd-亚克力机箱 - 单', '详情', 'image');
|
|
|
|
const imageFiles = fs.readdirSync(imageDir).filter(file => file.endsWith('.jpg'));
|
|
|
|
console.log('📸 图片信息检查\n');
|
|
|
|
for (const imageFile of imageFiles) {
|
|
const imagePath = path.join(imageDir, imageFile);
|
|
const metadata = await sharp(imagePath).metadata();
|
|
|
|
console.log(`${imageFile}:`);
|
|
console.log(` 宽度: ${metadata.width}px`);
|
|
console.log(` 高度: ${metadata.height}px`);
|
|
console.log(` 格式: ${metadata.format}`);
|
|
console.log('');
|
|
}
|
|
}
|
|
|
|
checkImageInfo().catch(error => {
|
|
console.error('💥 检查过程出错:', error);
|
|
process.exit(1);
|
|
});
|