fix: 增加索尼相机照片比例处理

This commit is contained in:
2026-07-03 16:13:30 +08:00
parent d277a6118f
commit e5dd163d22
4 changed files with 31 additions and 7 deletions
+7 -4
View File
@@ -36,10 +36,13 @@ function processImage(inputPath, outputPath) {
{ stdio: 'inherit' }
);
} else {
const newSize = getTargetSize(type, dimensions.width, dimensions.height);
console.log(` 目标尺寸: ${newSize}`);
const target = getTargetSize(type, dimensions.width, dimensions.height);
console.log(` 目标尺寸: ${target.size}${target.crop ? '' : ' (保持比例)'}`);
const resizeArgs = target.crop
? `-gravity center -resize "${target.size}^" -extent "${target.size}"`
: `-resize "${target.size}"`;
execSync(
`magick "${inputPath}" -gravity center -resize "${newSize}^" -extent "${newSize}" -quality 80 "${finalOutputPath}"`,
`magick "${inputPath}" ${resizeArgs} -quality 80 "${finalOutputPath}"`,
{ stdio: 'inherit' }
);
}
@@ -67,7 +70,7 @@ function processImage(inputPath, outputPath) {
async function runFormatTool(rl) {
console.log('\n🎨 图片格式转换工具');
console.log('='.repeat(50));
console.log('支持类型: iPhone (4:3 JPG) · 索尼相机 (3:2 JPG) · 截图 (WebP)');
console.log('支持类型: iPhone (4:3 JPG) · 索尼相机 (3:2 JPG) · 截图 (WebP) · 小米手机 (4:3 JPG)');
const inputDir = await question(rl, '\n📁 请输入图片所在目录 (留空使用当前目录): ');
const sourceDir = inputDir.trim() || process.cwd();