fix: 图片工具转换图片自动去除修复旋转字段,去除旧版脚本
This commit is contained in:
@@ -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}`);
|
||||
|
||||
Reference in New Issue
Block a user