更新产品配置和技能定义

This commit is contained in:
12600k-rog-d4
2026-04-05 02:34:24 +08:00
parent 40d9daf42a
commit 2d6afa0a01
64 changed files with 3299 additions and 1228 deletions

View File

@@ -0,0 +1,27 @@
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);
});

View File

@@ -0,0 +1,58 @@
const puppeteer = require('puppeteer');
const path = require('path');
const fs = require('fs');
async function convertHtmlToPng() {
console.log('🚀 启动 HTML 转 PNG 转换工具...\n');
const browser = await puppeteer.launch({
headless: 'new',
args: ['--no-sandbox', '--disable-setuid-sandbox']
});
const page = await browser.newPage();
await page.setViewport({ width: 1000, height: 1000 });
const detailDir = 'G:\\stonelan-workspace\\membank\\产品\\飞牛 NAS\\fyd-亚克力机箱 - 单\\主图';
const htmlFiles = fs.readdirSync(detailDir)
.filter(file => file.endsWith('.html'));
console.log(`📁 找到 ${htmlFiles.length} 个 HTML 文件需要转换\n`);
for (const htmlFile of htmlFiles) {
try {
const htmlPath = path.join(detailDir, htmlFile);
const pngFile = htmlFile.replace('.html', '.png');
const pngPath = path.join(detailDir, pngFile);
console.log(`📄 正在转换: ${htmlFile}`);
const fileUrl = `file:///${htmlPath.replace(/\\/g, '/')}`;
await page.goto(fileUrl, {
waitUntil: 'networkidle0',
timeout: 10000
});
await page.screenshot({
path: pngPath,
fullPage: true,
type: 'png'
});
console.log(`✅ 已生成: ${pngFile}\n`);
} catch (error) {
console.error(`❌ 转换失败 ${htmlFile}: ${error.message}\n`);
}
}
await browser.close();
console.log('✨ 所有转换任务已完成!');
}
convertHtmlToPng().catch(error => {
console.error('💥 转换过程出错:', error);
process.exit(1);
});

View File

@@ -0,0 +1,60 @@
const puppeteer = require('puppeteer');
const path = require('path');
const fs = require('fs');
async function convertHtmlToPng() {
console.log('🚀 启动主图 HTML 转 PNG 转换工具...\n');
const browser = await puppeteer.launch({
headless: 'new',
args: ['--no-sandbox', '--disable-setuid-sandbox']
});
const page = await browser.newPage();
// 主图尺寸 800x800
await page.setViewport({ width: 1000, height: 1000 });
const mainImageDir = 'G:\\stonelan-workspace\\membank\\产品\\飞牛 NAS\\fyd-亚克力机箱 - 单\\主图';
const htmlFiles = fs.readdirSync(mainImageDir)
.filter(file => file.endsWith('.html') && file.includes('主图'));
console.log(`📁 找到 ${htmlFiles.length} 个主图 HTML 文件需要转换\n`);
for (const htmlFile of htmlFiles) {
try {
const htmlPath = path.join(mainImageDir, htmlFile);
const pngFile = htmlFile.replace('.html', '.png');
const pngPath = path.join(mainImageDir, pngFile);
console.log(`📄 正在转换: ${htmlFile}`);
const fileUrl = `file:///${htmlPath.replace(/\\/g, '/')}`;
await page.goto(fileUrl, {
waitUntil: 'networkidle0',
timeout: 10000
});
await page.screenshot({
path: pngPath,
fullPage: false,
type: 'png',
clip: { x: 0, y: 0, width: 1000, height: 1000 }
});
console.log(`✅ 已生成: ${pngFile}\n`);
} catch (error) {
console.error(`❌ 转换失败 ${htmlFile}: ${error.message}\n`);
}
}
await browser.close();
console.log('✨ 所有主图转换任务已完成!');
}
convertHtmlToPng().catch(error => {
console.error('💥 转换过程出错:', error);
process.exit(1);
});

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,20 @@
{
"name": "membank",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git@gitee.com:xiongmaojames/membank.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": "",
"dependencies": {
"puppeteer": "^24.40.0",
"sharp": "^0.34.5"
}
}

View File

@@ -0,0 +1,64 @@
# -*- coding: utf-8 -*-
"""
产品图片抠图工具
使用rembg库自动去除图片背景
"""
import os
import sys
try:
from rembg import remove
from PIL import Image
except ImportError:
print("Missing dependencies, installing...")
os.system("pip install rembg pillow")
from rembg import remove
from PIL import Image
def remove_background(input_path, output_path):
"""
去除图片背景
"""
try:
print(f"Processing: {input_path}")
# 打开原始图片
with open(input_path, 'rb') as input_file:
input_data = input_file.read()
# 去除背景
output_data = remove(input_data)
# 保存结果
with open(output_path, 'wb') as output_file:
output_file.write(output_data)
print(f"Saved: {output_path}")
return True
except Exception as e:
print(f"Error: {e}")
return False
if __name__ == "__main__":
# 产品图片路径
image_dir = r"g:\stonelan-workspace\membank\产品\飞牛 NAS\fyd-亚克力机箱 - 单\image"
# 要处理的图片
input_image = os.path.join(image_dir, "正面.jpg")
output_image = os.path.join(image_dir, "正面_抠图.png")
# 检查文件是否存在
if not os.path.exists(input_image):
print(f"File not found: {input_image}")
sys.exit(1)
# 执行抠图
success = remove_background(input_image, output_image)
if success:
print(f"\nBackground removal completed!")
print(f"Original: {input_image}")
print(f"Result: {output_image}")
else:
print("\nBackground removal failed!")
sys.exit(1)

View File

@@ -0,0 +1,51 @@
const sharp = require('sharp');
const path = require('path');
const fs = require('fs');
const CROP_BOTTOM_HEIGHT = 300;
async function removeWatermark() {
console.log('🖼️ 开始裁剪图片水印...\n');
const imageDir = path.join(__dirname, '产品', '飞牛 NAS', 'fyd-亚克力机箱 - 单', '详情', 'image');
const backupDir = path.join(imageDir, 'backup');
const imageFiles = fs.readdirSync(backupDir).filter(file => file.endsWith('.jpg'));
console.log(`📸 找到 ${imageFiles.length} 张图片需要处理\n`);
console.log(`✂️ 裁剪设置: 从底部裁剪 ${CROP_BOTTOM_HEIGHT}px\n`);
for (const imageFile of imageFiles) {
try {
const backupPath = path.join(backupDir, imageFile);
const imagePath = path.join(imageDir, imageFile);
console.log(`📄 正在处理: ${imageFile}`);
const metadata = await sharp(backupPath).metadata();
const newHeight = metadata.height - CROP_BOTTOM_HEIGHT;
await sharp(backupPath)
.extract({
left: 0,
top: 0,
width: metadata.width,
height: newHeight
})
.toFile(imagePath);
console.log(` ✅ 已裁剪: ${metadata.width}x${metadata.height} -> ${metadata.width}x${newHeight}\n`);
} catch (error) {
console.error(` ❌ 处理失败 ${imageFile}: ${error.message}\n`);
}
}
console.log('✨ 所有图片处理完成!');
}
removeWatermark().catch(error => {
console.error('💥 处理过程出错:', error);
process.exit(1);
});

View File

@@ -0,0 +1,58 @@
const puppeteer = require('puppeteer');
const path = require('path');
const fs = require('fs');
async function convertMainImageToPng() {
console.log('🎨 启动主图渲染工具...\n');
const browser = await puppeteer.launch({
headless: 'new',
args: ['--no-sandbox', '--disable-setuid-sandbox']
});
const page = await browser.newPage();
await page.setViewport({ width: 800, height: 800 });
const mainImageDir = 'G:\\stonelan-workspace\\membank\\产品\\飞牛 NAS\\fyd-亚克力机箱 - 单\\主图';
const htmlFiles = fs.readdirSync(mainImageDir)
.filter(file => file.endsWith('.html'));
console.log(`📁 找到 ${htmlFiles.length} 个主图HTML文件需要渲染\n`);
for (const htmlFile of htmlFiles) {
try {
const htmlPath = path.join(mainImageDir, htmlFile);
const pngFile = htmlFile.replace('.html', '.png');
const pngPath = path.join(mainImageDir, pngFile);
console.log(`📄 正在渲染: ${htmlFile}`);
const fileUrl = `file:///${htmlPath.replace(/\\/g, '/')}`;
await page.goto(fileUrl, {
waitUntil: 'networkidle0',
timeout: 10000
});
await page.screenshot({
path: pngPath,
fullPage: true,
type: 'png'
});
console.log(`✅ 已生成: ${pngFile}\n`);
} catch (error) {
console.error(`❌ 渲染失败 ${htmlFile}: ${error.message}\n`);
}
}
await browser.close();
console.log('✨ 所有主图渲染完成!');
}
convertMainImageToPng().catch(error => {
console.error('💥 渲染过程出错:', error);
process.exit(1);
});