fix: 图片工具转换图片自动去除修复旋转字段,去除旧版脚本

This commit is contained in:
2026-09-10 14:01:26 +08:00
parent b9682de64a
commit 427c92b9ec
7 changed files with 101 additions and 234 deletions
+5 -2
View File
@@ -34,8 +34,11 @@ function question(rl, prompt) {
// 获取图片尺寸
function getImageDimensions(filePath) {
try {
const width = execSync(`identify -format "%w" "${filePath}"`, { encoding: 'utf-8' }).trim();
const height = execSync(`identify -format "%h" "${filePath}"`, { encoding: 'utf-8' }).trim();
// -auto-orient:按 EXIF Orientation 换算视觉宽高,避免竖拍图被当成横图
const output = execSync(`identify -auto-orient -format "%w %h" "${filePath}"`, {
encoding: 'utf-8',
}).trim();
const [width, height] = output.split(/\s+/);
return { width: parseInt(width), height: parseInt(height) };
} catch (error) {
console.error(`获取图片尺寸失败: ${filePath}`);